Possible Duplicate:
How do i specify wcf behaviorExtension class type without the assembly version number?
In my web application hosted on IIS7 I have a project X referencing project Y (project reference in VS2010). I’m trying to add behaviorExtensions with types from Y in X’s web.config without specifying version number.
I’m adding a behaviorExtension under System.ServiceModel.Extensions.
<behaviorExtensions>
<add name="serviceKeyBehavior" type="MyNS.ServiceSupport.ServiceKeyBehaviorExtensionElement, Analyst.API"/>
<add name="userNameClientCredentials" type="MyNS.ServiceSupport.UserNameClientCredentialsElement, Analyst.API" />
</behaviorExtensions>
I haven’t been able to make it work without specifying e.g.
Version=3.2.1.0, Culture=neutral, PublicKeyToken=null
at the end of the type attribute.
Usually just leaving out the version info above works fine.
If I change
type="MyNS.ServiceSupport.ServiceKeyBehaviorExtensionElement, Analyst.API"
to
type="MyNS.ServiceSupport.ServiceKeyBehaviorExtensionElement, Analyst.API, Version=3.2.1.0, Culture=neutral, PublicKeyToken=null"
(3.2.1.0 == Current DLL version), it works.
Otherwise it claims it doesn’t find the type:
An error occurred creating the configuration section handler for
system.serviceModel/behaviors: Extension element ‘serviceKeyBehavior’
cannot be added to this element. Verify that the extension is
registered in the extension collection at
system.serviceModel/extensions/behaviorExtensions. Parameter name:
element (C:\inetpub\wwwroot\xyz\web.config line 155)
Check eventlog (ID: 1265) for more information.
Any thoughts?
I found this blog post from 2008:
http://keyvan.io/configuration-error-for-custom-behavior-extensions-in-wcf
It seems to be a bug in WCF.
I tried recompiling it with .Net framework 4.0 and then it works fine.
There is also a thread here at StackOverflow describing this which I didn’t find before:
How do i specify wcf behaviorExtension class type without the assembly version number?