开发者

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

I'm able t开发者_运维技巧o 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.

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

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

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

2


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜