C# WCF中关于serviceHostingEnvironment的未处理错误
我是一个尝试WCF的新手。我试图使用android访问WCF,我遇到了麻烦,根据我的研究,访问WCF需要json,所以我尝试将其更改为json 我将接口更改为对象类型,并开始出现如下所示的错误C# WCF中关于serviceHostingEnvironment的未处理错误,c#,wcf,rest,C#,Wcf,Rest,我是一个尝试WCF的新手。我试图使用android访问WCF,我遇到了麻烦,根据我的研究,访问WCF需要json,所以我尝试将其更改为json 我将接口更改为对象类型,并开始出现如下所示的错误 The exception message is: The type 'AddItemService.Login', provided as the Service attribute value in the ServiceHost directive, or provided in the confi
The exception message is: The type 'AddItemService.Login', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
我的接口方法:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "Login", BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
[Description("Returns the Login User ID")]
int GetUserId(Login login);
my web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="AddItemService.Login"
behaviorConfiguration="RESTBehavior">
<endpoint address=""
binding="webHttpBinding"
contract="AddItemService.ILogin"
behaviorConfiguration="MyEndpointBehavior"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyEndpointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
我不知道为什么它不起作用。有人能帮我吗?听起来像是WCF服务的.svc文件中指定的服务类型(实际的标记文件,而不是代码隐藏文件)引用的是不存在的服务类类型
如果在Visual Studio中右键单击.svc文件并选择“查看标记”,则该文件中ServiceHost指令的“服务”属性需要包含实现WCF服务接口的类的名称。听起来它现在引用的是不存在的
AddItemService.Login
。GetUserId操作的一个参数的参数类型是“Login”,但服务类型也是“Login”。它们在不同的命名空间中是两种不同的类型吗?如果不是,那可能是您的问题-服务名称是服务的实现,在您的情况下,实现AddItemService.ILogin的就是服务的实现