在服务“服务”实施的合同列表中找不到合同名称“SelfHostedRESTService.IService”。 [英] The contract name 'SelfHostedRESTService.IService' could not be found in the list of contracts implemented by the service 'Service'.

查看:93
本文介绍了在服务“服务”实施的合同列表中找不到合同名称“SelfHostedRESTService.IService”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



当我尝试将现有的基于IIS的休息服务移植到自托管服务时,我遇到以下异常。



在服务'服务'实施的合同列表中找不到合同名称'SelfHostedRESTService.IService'。



在成功测试此处给出的示例代码之前,我按照以下URL来移植现有代码。



http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/self-hosted-wcf-rest-service-or-hosting-wcf-rest-service -in-console-application / [ ^ ]



这是我的app.config内容



Hi All,

I have got the following exception, when I tried to port an existing IIS based rest service to a self hosted one.

The contract name 'SelfHostedRESTService.IService' could not be found in the list of contracts implemented by the service 'Service'.

I was following the below URL to port my existing code, before successfully testing the sample code given in this.

http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/self-hosted-wcf-rest-service-or-hosting-wcf-rest-service-in-console-application/[^]

Here is my app.config contents

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
  
 

  <appSettings/>
  <connectionStrings/>
  <system.web>
    <webServices>
      <protocols>
        <add name="HttpSoap" />
        <add name="HttpGet" />
        <add name="HttpPost" />
      </protocols>
    </webServices>
   
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Core, Version=4.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
  
    <authentication mode="Windows"/>

    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </controls>
    </pages>
    <httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
    <identity impersonate="false" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </handlers>
  </system.webServer>

  <system.serviceModel>
    
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IService" closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"

                 bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"

                 maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="10:10:00" enabled="false" />
        </binding>
      </wsHttpBinding>
    </bindings>
    
    <services>
      <service name="SelfHostedRESTService.Service" behaviorConfiguration="SelfHostedRESTService.RestServiceBehavior">
        <endpoint address="SelfHostedRESTService.Service" binding="webHttpBinding" contract="SelfHostedRESTService.IService" behaviorConfiguration="web">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    
    <behaviors>
      <serviceBehaviors>
        <behavior name="SelfHostedRESTService.RestServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    
  </system.serviceModel>

</configuration>





I am not sure, why it is throwing this exception, If someone could shed some light to it, that would be grateful.



Thanks in advance

Sebastian



I am not sure, why it is throwing this exception, If someone could shed some light to it, that would be grateful.

Thanks in advance
Sebastian

推荐答案

这篇关于在服务“服务”实施的合同列表中找不到合同名称“SelfHostedRESTService.IService”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆