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?
Try this:
<behaviorExtensions>
<add
name="clientCredentialsExtension"
type="Simon.Web.Giftcard.WCFSecurity.ClientCredentialsExtensionElement, Simon.Web.Giftcard"/>
</behaviorExtensions>
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 .
Apparently it's fixed in .Net 4.0 beta 2. Not much use to me, who is stuck with 3.5.
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