0

My WCF - configuration runs just fine on my developer machine. When I try to release it to the demonstration environment (another server), it will give me following error:

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

My configuration, which is in both cases the same:

<system.serviceModel>
    <services>
        <service name="UI.WS.Services.MyService" behaviorConfiguration="ServiceBehavior">
            <endpoint address="" binding="wsHttpBinding" 
                      contract="UI.WS.Services.IMyService" 
                      bindingConfiguration="WsSecurityMode">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <serviceMetadata httpGetEnabled="true" />
                <!-- Extension -->
                <log4net />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <wsHttpBinding>
            <binding name="WsSecurityMode">
                <security mode="None" />
            </binding>
        </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <extensions>
        <behaviorExtensions>
            <!-- Extension -->
            <add name="log4net" type="UI.WS.ErrorHandling.Log4NetBehaviorExtensionElement,UI,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
        </behaviorExtensions>
    </extensions>
</system.serviceModel>

I already checked this hint, this is not the problem (and if it would be, it wouldn't run under development environment either I guess).

Any suggestions?

Community
  • 1
  • 1
sl3dg3
  • 5,026
  • 12
  • 50
  • 74

1 Answers1

1

Well, I tried typeof(UI.WS.ErrorHandling.Log4NetBehaviorExtensionElement).AssemblyQualifiedName which gives me UI.WS.ErrorHandling.Log4NetBehaviorExtensionElement, UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. This works now in both environments. To me it is an oddity - why did the first version (without blank spaces) work on my developer machine? In both environments, the application pools do run under .Net 4.0.3, so no difference here. Furthermore I remember vaguely reading somewhere, blank spaces in the type declaration should be left away due to a bug of WCF, which doesn't seem to be the case here.

Either way, this works now like that:

<add name="log4net" type="UI.WS.ErrorHandling.Log4NetBehaviorExtensionElement, UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
sl3dg3
  • 5,026
  • 12
  • 50
  • 74