Cry about...
Dynamics CRM 2015 Troubleshooting


This collection already contains an address with scheme http


Symptom:

When connecting to the discovery service via software the following error is returned:

Metadata contains a reference that cannot be resolved: 'http://10.0.0.21/_common/error/errorhandler.aspx?BackUri=&ErrorCode=&Parm0=%0d%0a%0d%0a
Error Details: The service '%2fXRMServices%2f2011%2fDiscovery.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel%2fserviceHostingEnvironment%2fmultipleSiteBindingsEnabled' to true or specifying 'system.serviceModel%2fserviceHostingEnvironment%2fbaseAddressPrefixFilters'.%0d%0aParameter name: item.&RequestUri=%2fXRMServices%2f2011%2fDiscovery.svc%3fwsdl&user_lcid=1033'."

When browsing to http://server/XRMServices/2011/Discovery.svc (where "server" is the name or IP address of your Dynamics CRM server plus port if required), the following unhelpful error is returned:

Error

An error has occurred.

Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions ...

The same error can be observed when logging in using a browser other than Internet Explorer after being prompted for a username and password.

If you look in the Windows event log (in the Application log) you will see two very similar errors logged:

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/65153934
Exception: System.ServiceModel.ServiceActivationException: The service '/XRMServices/2011/Discovery.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.

and

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/65153934
Exception: System.ServiceModel.ServiceActivationException: The service '/XRMServices/2011/Discovery.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.

Cause:

It looks like Dynamics CRM 2015 expects to be bound to a single port, and if it is bound to more than one port then there are extra steps to go through.

Possible Remedies:

You will only want to implement one of these:

  • Only use one binding.

    On the server that is hosting Dynamics CRM 2015 check the Bindings in IIS. IIS → Sites → Microsoft Dynamics CRM → Bindings ...

    If there is more than one binding listed then delete all the bindings other than the one required.

    Proceed with caution! If there are other bindings then consider first why those other bindings exist. If you need more than one binding then consider the next solution.

    Be aware that whilst it is possible to configure the discovery service to support multiple bindings, those bindings cannot be of the same type - so it can be configured to support HTTP and HTTPS, but not HTTP and HTTP (even if bound to different ports).

  • Enable multiple bindings in the Dynamics CRM 2015 configuration.

    Edit the following file using notepad:

    C:\Program Files\Microsoft Dynamics CRM\CRMWeb\web.config

    It might be wise to take a backup of this file before making any edits. You will probably need to run notepad as administrator in order to be able to save any changes to the file.

    Find the section:

    <system.serviceModel>
        <serviceHostingEnvironment .../>
    </system.serviceModel>

    What you need to do is to add:

    multipleSiteBindingsEnabled="true" to serviceHostingEnvironment.

    Mine looked like this:

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0" />
    </system.serviceModel>

    so adding multipleSiteBindingsEnabled="true" changed it to:

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>

    In order for this change to take effect, the deployment service needs to be restarted. Open up IIS, navigate to the CrmDeploymentServiceAppPool and Recyle it. So IIS → Server Name → Application Pools → CrmDeploymentServiceAppPool → Right click and select "Recycle ..."

    If you continue to get errors then check the Windows event log. Also remember the warning given above that even though it can be made to support multiple bindings those bindings must still be of different types (so it cannot support two http bindings even when those are to different ports).


These notes have been tested with Microsoft Dynamics CRM 2015, and may apply to other versions as well.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.