How do i specify wcf behaviorExtension class type without the assembly version number?

自作多情 提交于 2019-11-28 09:35:48

问题


I have a web app that uses a WCF service that utilizes a behaviorExtension like so:

<behaviorExtensions>
<add name="clientCredentialsExtension" type="Simon.Web.Giftcard.WCFSecurity.ClientCredentialsExtensionElement, Simon.Web.Giftcard, Version=1.0.3736.20411, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>

The problem is this web app's version changes with every compile (i think) and thus invalidating this entry.

How can I avoid having to change the version number every time I compile this? Can I specify the extension in code somewhere?


回答1:


Try this:

<behaviorExtensions>
    <add 
        name="clientCredentialsExtension"         
        type="Simon.Web.Giftcard.WCFSecurity.ClientCredentialsExtensionElement, Simon.Web.Giftcard"/>
</behaviorExtensions>



回答2:


If you are stuck with .NET 3.5 where the configuration bug is not fixed yet, the solution is to implement IServiceBehavior by your service. See this article, example 6-15 .




回答3:


Apparently it's fixed in .Net 4.0 beta 2. Not much use to me, who is stuck with 3.5.

http://connect.microsoft.com/wcf/feedback/details/216431/wcf-fails-to-find-custom-behaviorextensionelement-if-type-attribute-doesnt-match-exactly




回答4:


This annoying bug bit me before too. I eventually changed all mine to build up in code instead of in the config.



来源:https://stackoverflow.com/questions/2518425/how-do-i-specify-wcf-behaviorextension-class-type-without-the-assembly-version-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!