Search code examples
wcfbindingconflict

A binding instance has already been associated to listen URI .after moving from .NET 4.0 to 4.5


After 3 days of never ending search I am posting this. Please help. The following is the config file I have. There is only one endpoint specified , but its saying there is a conflict in the endpoints. Please help me rectifying this conflict.

System.InvalidOperationException: A binding instance has already been associated to listen URI 'http://dd.myserver.net/MyWebService/MyService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
    <add key="wcf:webservicehost:enableautomaticendpointscompatability" value="true"/>
  </appSettings>
 
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <authentication mode="None"/>
    <customErrors mode="Off"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="MyRESTService.MyService">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="MyRESTService.IMyService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
          <security mode="None">
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" scheme="http"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="false"/>
  </system.webServer>
</configuration>

Solution

  • Finally I resolved the error given by one guy [https://stackoverflow.com/questions/12643113/wcf-conflicting-endpoints-after-net-4-5-installation/39394010]

    I have just removed the security tag inside

    before

     <webHttpBinding>
            <binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
              <security mode="None">
              </security>
            </binding>
          </webHttpBinding>
    

    After

    <webHttpBinding>
            <binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
             </binding>
          </webHttpBinding>
    

    This little thing took me 3 days of search. thanks to stackoverflow.