Custom binding element can't be loaded in WCF under IIS, however it can load under WCF Self-Host

939 Views Asked by At

I'm able to run the WCF-SecureProfile sample that comes with the MSFT WCF samples download (http://msdn.microsoft.com/en-us/library/ee818238.aspx)

However I can't port this server component to IIS. I get the error that <MakeConnectionBindingElement/> can't be loaded. Considering that I have the behavior extensions loaded I don't know why IIS can't see the extension, however the self-host version of my app can.enter image description here

I uploaded the sourcecode of the project into codeplex for easy browsing. Here is a direct link to web.config and all other files.

enter image description here2

1

There are 1 best solutions below

0
On BEST ANSWER

I got the sample and set it up to run on IIS local. I didn't get the same issue as the one in this question but I did run into a big gotcha. Accessing the service in IIS gave me this error message:

Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.

After some head scratching, I found the cause of this issue. WCF 4 now assigns default bindings to each transport (I'm liking this feature less & less). For the HTTP transport, the default binding is basicHttpBinding. The problem is the customBinding config does not override any default binding. This causes WCF to attempt to configure duplex over basicHttpBinding which of course isn't supported. The fix is to turn off the default transport mapping for HTTP and assign it to your custom binding as shown below for this service:

    <protocolMapping>
        <clear/> <!-- removes all defaults which you may or may not want. -->
        <!-- If not, use <remove scheme="http" /> -->
        <add scheme="http" binding="customBinding" bindingConfiguration="rspBinding"/>
    </protocolMapping>

Once I added this to the serviceModel element, the IIS based service worked just fine.