I'm trying to add the CORS headers to a WCF service which is part of a precompiled web site project in VS 2012.
The error
The type 'EnableCrossOriginResourceSharingBehavior, MyWebSite, Version=0.0.0.0, Culture=neutral' registered for extension 'crossOriginResourceSharingBehavior' could not be loaded.
from the config file
<behaviors>
<serviceBehaviors>...</serviceBehaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp />
<crossOriginResourceSharingBehavior /> <!-- Error Here -->
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="crossOriginResourceSharingBehavior" type="EnableCrossOriginResourceSharingBehavior, MyWebSite, Version=0.0.0.0, Culture=neutral" />
</behaviorExtensions>
</extensions>
Now, there is no MyWebSite.dll
in a precompiled site, apparently. So, how do I get past this and make the BehaviorExtension work?
You have that error because the definition has a wrong type: you lost namescpace of the type.
Probably the version is wrong, because it equals to
0.0.0.0
in the definition. SeeAssemblyInfo.cs
for the assembly version.I see the assembly hasn't a strong name. So you can remove Version and Culture from the definition.