locked
WCF - Conflicting endpoints after .Net 4.5 installation RRS feed

  • Question

  • User301138917 posted

    Hi,
    I'm recently installed the 4.5 framework on our development web server which runs IIS 7.5 on Windows Server 2008.  After installation, two web services started having the same error.  These web services were built using the MS REST Starter Kit.  Here is the error I'm getting.

    A binding instance has already been associated to listen URI <url> . 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. 

    Here is a copy of the system.service model sectino of our config file. 
      <system.serviceModel>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />  
        <bindings>
          <webHttpBinding>
            <binding>
              <security mode="Transport" />
            </binding>
          </webHttpBinding>
          <wsHttpBinding>
            <binding name="EnterpriseIdentityBinding" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
              textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
              <security mode="TransportWithMessageCredential">
                <transport clientCredentialType="None" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="UserName" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
       
        <client>
          <endpoint address="https://betaapps/EnterpriseIdentity/V1/UserService.svc"
            binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
            contract="UserServiceWCF.IUserService" name="wsSecureUsers" />
          <endpoint address="https://betaapps/EnterpriseIdentity/V1/RoleService.svc"
            binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
            contract="RoleServiceWCF.IRoleService" name="wsSecureRoles" />
        </client>
     
        <standardEndpoints>
          <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
          </webHttpEndpoint>
        </standardEndpoints>

        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceAuthorization principalPermissionMode="Custom">
                <authorizationPolicies>
                  <add policyType="Hsmv.Web.Security.IdentityModel.HttpContextWithRolesPolicy, Hsmv.Web.Security" />
                </authorizationPolicies>
              </serviceAuthorization>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

     Any idea why this error would occur after installing .Net 4.5?
    Thanks!

    Thursday, September 27, 2012 3:37 PM

Answers

  • User-1000095884 posted

    No, the issue does not occur on .NET 4.0. 

    Can you email on netfx45compat at Microsoft dot com(netfx45compat@microsoft.com) with following information.

    1. Code that reproduces the problem.
    2. Operating System

    Thanks!

    Best Regards,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 1, 2012 9:16 PM

All replies

  • User301138917 posted

    I would like to add that I tried removing this section and it works without it.
    <webHttpBinding>
            <binding>
              <security mode="Transport" />
            </binding>
    </webHttpBinding>

    I use this because this service runs on ssl.  I heard that WCF 4.5 tries to create bindings and endpoints for you so they don't need to be in the web.config.  So I wondered if this section is being automatically built by WCF and is not needed.  Or is my thinking incorrect?

    Thanks!

    Thursday, September 27, 2012 4:20 PM
  • User-1000095884 posted

    Hi Shawn2012,

    Does the same issue reproduce on .NET 4.0?

    Best Regards,

    Monday, October 1, 2012 1:18 AM
  • User301138917 posted

    Haixia Xie,
    No, the issue does not occur on .NET 4.0. 

    Monday, October 1, 2012 8:02 AM
  • User-1000095884 posted

    No, the issue does not occur on .NET 4.0. 

    Can you email on netfx45compat at Microsoft dot com(netfx45compat@microsoft.com) with following information.

    1. Code that reproduces the problem.
    2. Operating System

    Thanks!

    Best Regards,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 1, 2012 9:16 PM
  • User591515215 posted

    Hello,

    I have the same problem. Everything worked fine before the 4.5 upgrade. My configuration is as follows:

    • IIS Version 7.0.6000.16386 - with http and https bindings added for the entire website.  (Note that I have the same problem on another machine running IIS 7.5.7600.16385 with the identical configuration below.)
    • IIS Application under the website
      • Hosts an html page which in turn hosts a Silverlight 5 app.
      • Uses URL Rewrite module to redirect http requests to https requests. (We want both bindings so that redirects are possible.)
      • App pool: .NET Framework v4.0.30319 (no option for .NET 4.5 since it is an in place upgrade I assume), Integrated pipeline mode.
    • Second IIS Application under the above IIS application hosting WCF services used by the Silverlight app.
      • URL Rewrite module is *not* used for this app.
      • App pool: .NET Framework v4.0.30319, Integrated pipeline mode.

    With .NET 4.0, I could access the html page from my browser using https or http (which redirected to https) and login (which is done via a WCF call).

    After the .NET 4.5 upgrade, I can access the html page as described above, but when logging in (when calling WCF), I get the following error:

    WebHost failed to process a request.  Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/62476613  Exception: System.ServiceModel.ServiceActivationException: The service '<relative url to WCF service>' cannot be activated due to an exception during compilation.  The exception message is: A binding instance has already been associated to listen URI '<full url to WCF service>'. 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. . ---> System.InvalidOperationException: A binding instance has already been associated to listen URI '<full url to WCF service>'. 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.    at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)    at System.ServiceModel.ServiceHostBase.InitializeRuntime()    at System.ServiceModel.ServiceHostBase.OnBeginOpen()    at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)    at System.ServiceModel.Channels.CommunicationObject.Open()    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)    --- End of inner exception stack trace ---    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)    at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)  Process Name: w3wp  Process ID: 5004

    I can workaround this error by simply removing the https binding from the parent IIS website, but then users cannot reach the site with http and have it redirected. If it was possible, I would remove the https binding from just the WCF IIS app, but bindings cannot be modified at that level in IIS. 

    Here are my service model settings in the WCF web.config:

      <system.serviceModel>
        <diagnostics wmiProviderEnabled="true"/>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <webHttpBinding>
            <binding maxReceivedMessageSize="10490000" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:01:00" closeTimeout="00:01:00" allowCookies="true">
              <security mode="Transport"/>
            </binding>
          </webHttpBinding>
        </bindings>
        <protocolMapping>
          <clear/>
          <add scheme="http" binding="webHttpBinding"/>
        </protocolMapping>
      </system.serviceModel>

     Any help would be greatly appreciated.

    Thanks,

    -James

    Tuesday, October 30, 2012 3:28 PM
  • User274339123 posted

    Hi James,

    Please refer to this post for a solution for the issue described in this thread. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/33cdb290-b376-429a-99ef-37d8bfa13d7d

    However in your case I see you don't have a standard endpoint. Instead you have an explicitly defined endpoint. I am unable to reproduce this issue for your case. I looked at your web.config. It seems to miss the <webHttp /> endpoint behavior. Could you upload a stand alone repro somewhere so that somebody can have a look?

    Thanks,

    Friday, November 9, 2012 2:43 PM
  • User591515215 posted

    Hi prabht (Praburaj Thiagarajan?),

    Thank you for your help. I removed all application specific code and reduced my web service to a single test method: /EntityService/Test. If the IIS 7 website has a single binding added (http or https), it will return "OK". If it has multiple bindings added (http and https), the service will throw the following error:

    "A binding instance has already been associated to listen URI 'http://[machine]/ReproWebServices/EntityService'. 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."

    Here is the source: https://skydrive.live.com/?cid=4245cdbbe219133f#cid=4245CDBBE219133F&id=4245CDBBE219133F%21119.

    James

    Monday, November 12, 2012 1:47 PM
  • User304515767 posted

    I have this exact same problem.   The webconfig workaround won't work for me since I am dynamically adding my endpoints(ServiceRoutes) in code at startup.  

    Like James, if I remove the http binding from my root IIS site I do not get the error.   This won't work since my root site need IIS and WCF Rest sub-site need https.

    Any word on a fix?    

    Monday, January 21, 2013 4:42 PM