错误是:
找不到类型“WF.XXX.WebServices.XXXXService”,作为 ServiceHost 指令中的服务属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。
堆栈跟踪:
[InvalidOperationException:找不到类型“WF.XXX.WebServices.XXXXService”,作为 ServiceHost 指令中的 Service 属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。]
System.ServiceModel.Activation .ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +52742
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1459
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String标准化虚拟路径)+623[ServiceActivationException:服务'/XXXXX/XXXXXService/XXXXService.svc'由于编译过程中的异常而无法激活。异常消息是:类型“WF.XXX.WebServices.XXXXService”,作为 ServiceHost 指令中的服务属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供,找不到..] 系统。 Runtime.AsyncResult.End(IAsyncResult 结果) +687598 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult 结果) +190 System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest
(IAsyncResult ar) +304662
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult a) +94
如何在服务器上修复此错误?
2012 年 9 月 18 日更新: 我的机器上安装了 Visual Studio 2012 和 .NET Framework 4.5,但服务器只有 .NET Framework 4.0。我不确定这是否重要,因为我使用 .NET Framework 4.0 构建了该服务。
但奇怪的是,当我运行我的项目时,我注意到了 4.5 的功能。它显示了一个指向单个 WSDL 文件的 URL,这在 .NET 4.0 版本中不可用。为什么在使用 .NET Framework 4.0 构建项目时会出现这种情况?这是屏幕截图:
2012 年 9 月 19 日更新:
这是相关的 web.config 文件:
<system.serviceModel>
<services>
<service name="XXXXService">
<!-- Use a bindingNamespace to eliminate tempuri.org -->
<endpoint address="" name="XXXXService"
binding ="basicHttpBinding"
bindingNamespace="@services.url@/XXXXService"
contract="WF.XXX.WebServices.XXXXService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>