Thursday, October 18, 2012

An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'XXX' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.

A web.config of project include next rows:
...
<extensions>
    <behaviorExtensions>
        <add name="ELEMENT" type="YYY.ZZZ,YYY.XXX, Version=1.0.0.0,Culture=neutral, PublicKeyToken=null" />
    </behaviorExtensions>
</extensions>
...
<behavior name="BehaviorName">
          ELEMENT />
</behavior>

In the start project WCF is throwing exception and message:
"An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'ELEMENT' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions."

A problem exists in file AssemblyInfo of YYY.XXX and not in config.
YYY.XXX change build number in every compilation but WCF is require a full name of assembly (AssemblyQualifiedName) and exact assembly file version number.

Open AssemblyInfo and see last 2 rows:
[assembly: AssemblyVersion(...)]
[assembly: AssemblyFileVersion(...)]

If a code looks like this:
[assembly: AssemblyVersion(5.0.1.0)]
[assembly: AssemblyFileVersion(5.0.1.0)]

You not reading current article but if acode looks like this:

[assembly: AssemblyVersion(5.0.1.0)]
[assembly: AssemblyFileVersion(5.0.1.*)]

This is a time to change it and resolve a problem. Enjoy.



No comments: