问题
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