我试图用IIS6托管我的服务,但我总是得到这个异常。
Server Error in '/WebServices' Application.
--------------------------------------------------------------------------------
The type 'QS.DialogManager.Communication.IISHost.RecipientService', provided as the Service attribute value in the ServiceHost directive could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type 'QS.DialogManager.Communication.IISHost.RecipientService', provided as the Service attribute value in the ServiceHost directive could not be found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The type 'QS.DialogManager.Communication.IISHost.RecipientService', provided as the Service attribute value in the ServiceHost directive could not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +6714599
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +604
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +46
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +654
[ServiceActivationException: The service '/WebServices/dm/RecipientService.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'QS.DialogManager.Communication.IISHost.RecipientService', provided as the Service attribute value in the ServiceHost directive could not be found..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +15626880
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +15546921
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +265
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +227
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
我完全没有线索,除了它似乎找不到我的程序集。代码应该使用公共类正确编译。
这是我的.svc文件:
<%@ ServiceHost Language="C#" Debug="true" Service="QS.DialogManager.Communication.IISHost.RecipientService" CodeBehind="RecipientService.svc.cs" %>
我试着创建一个非常非常简单的服务,它也不包含任何东西,看看这是否可以工作,但仍然显示相同的老错误。
The type 'IISHost.Service1', provided as the Service attribute value in the ServiceHost directive could not be found.
发布于 2009-11-05 04:56:47
该问题也可能存在于svc文件中与svc.cs文件中不同命名空间中。
svc文件中的命名空间必须采用以下格式。
Service="Namespace.SvcClassName"
发布于 2010-01-16 05:16:29
我知道这可能是“显而易见”的答案,但它让我被绊倒了一点。确保bin文件夹中有项目的dll。当服务发布时,发布它的人删除了dll,因为他认为它们在GAC中。在本例中,专门用于项目(QS.DialogManager.Communication.IISHost.RecipientService.dll,的那个)不在那里。
同样的错误是由于非常不同的原因。
发布于 2013-04-07 13:00:30
发生此错误的原因是.SVC文件中的服务名称不匹配。您可能已经更改了实现interface.The解决方案的服务类的名称,以便打开.SVC文件并与服务属性和CodeBehind属性完全匹配。因此,您的.SVC文件应该如下所示
<%@ ServiceHost Language="Language you are using" Debug="bool value to enable debugging" Service="Service class name that is implementing your Service interface" Codebehind="~/Appcode/Class implementing interface.cs"%>. for eg.
<%@ ServiceHost Language="C#" Debug="true" Service="Product.Service" CodeBehind="~/AppCode/Product.Service.cs"%>
此示例用于使用C#语言、启用调试、服务类实现接口的.svc文件,该类位于名为Service.cs的app文件夹中,产品是服务类的命名空间。
另外,请在服务配置文件中进行相应的更改。
<system.serviceModel>
<services>
<service name="Product.Service" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="Product.Iservice">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<behavior name="ServiceBehavior">
<serviceMetaData httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</behaviors>
</system.serviceModel>
https://stackoverflow.com/questions/720807
复制相似问题