找到了该合同的多个端点配置

我们正在使用WCF工作ASP.Net Web应用程序。 作为Windows服务托管的wcf服务。 一切皆好。 然后我们做了一个修改,以便服务契约具有不同的名称空间(从Namespace1.IserviceContract到Namespace2.IserviceContract)。 在我们尝试实例化服务对象后,我们部署到服务器并发生了以下错误。

    System.InvalidOperationException: An endpoint configuration section for contract 'Namespace2.IserviceContract' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

Generated: Fri, 06 Jul 2012 21:02:56 GMT


System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: An endpoint configuration section for contract 'Namespace2.IserviceContract' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
   at System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
   at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
   at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
   at System.ServiceModel.ClientBase`1..ctor()
   at TestApplication.ManagementWrapper.VerifyAuthentication(Int32 appId, String Token)
   at TestApplication.VerifyAuthentication(String tokenstring)

我们对此问题进行了研究,发现如果在我们的web.config文件中定义了两个客户端端点,则会出现此类型的异常。 但是我们确信我们只定义了一个客户端端点。 这个异常只会在服务器中显示。 本地工作正常。 这里是我们的服务模式:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_Management" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="4194304" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="32768" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://servername:9010/Management/service/ManagementService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Management" contract="Namespace2.IserviceContract" name="NetTcpBinding_IserviceContract" />
    </client>
  </system.serviceModel>

我们也尝试重新启动IIS和应用程序池。 仍然得到相同的例外。


尝试在您的web.config中搜索另一个使用该Web地址作为ManagementService的Web站点。 另外,在web.config中搜索对旧命名空间的引用(contract =“Namespace1.IserviceContract”)。 不要忘记检查额外的.config文件。 那个小窍门已经烧毁了我。


无论协议被称为基本,net.tcp或wshttp,该地址应该在web配置文件中从app.config文件中的客户端部分删除其他地址,在我的情况下,我打电话给服务为htp:// machinename:700 /test.svc但在客户端部分有net.tcp和wshttp配置的地址,删除了这些地址,问题对我来说是固定的。


请右键单击您的wcf服务的svc文件,然后单击查看标记。

然后在那里修改名称空间。 它应该工作得很好。

链接地址: http://www.djcxy.com/p/87193.html

上一篇: More than one endpoint configuration for that contract was found

下一篇: WCF Configuration for Endpoint in Another Project