WCF and LAB config problem

Topics: Logging Application Block
Oct 27, 2008 at 5:51 AM
Hi,
I've used the LAB before, but never with a WCF service.  I seem to be having a hard time configuring it.  I followed the directions in the doc
(-help://MS.VSCC.v90/MS.VSIPCC.v90/ms.practices.entlib.2008may/EntLib4Docs/html/EntLib2008May_4b216b82-b77d-41c3-bb14-cc1bf5d29db2.html)
but to no avail.  Then I tried cutting and pasting the sample app.config from that article into my project and just modifiying the WCF related ABCs.  Still no luck.

No matter what I try, I end up getting the following error when the service trys to start:

System.TypeInitializationException: The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Couldn't find type for class Microsoft.Practices.EnterpriseLibrary.Logging
                     .TraceListeners.EntLibLoggingProxyTraceListener,
                     Microsoft.Practices.EnterpriseLibrary.Logging.
....
...
It looks like it can't find the Microsoft.Practices.EnterpriseLibrary.Logging DLL.  I do have a reference to it in my project.  In fact I added references to all the DLLs in the EntLib Bin directory just to be sure I wasn't missing something.

If anyong can see anything wrong with the following file, or has any other ideas about what might be wrong, I would be very, very appreciative.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add source="Enterprise Library Logging" formatter="Text Formatter"
        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Formatted EventLog TraceListener" />
      <add fileName="trace-xml.log" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="XML Trace Listener" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="System.ServiceModel">
        <listeners>
          <add name="XML Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Formatted EventLog TraceListener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Formatted EventLog TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <services>
      <service behaviorConfiguration="MsServiceLibrary.Service1Behavior" name="MsServiceLibrary.MsService">
        <endpoint name="myNamedPipe" address="net.pipe://localhost/MsServiceLibary" binding="netNamedPipeBinding" contract="MsServiceLibrary.IMsService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/MsServiceLibrary/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="All">
        <listeners>
          <add name="traceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging&#xD;&#xA;                     .TraceListeners.EntLibLoggingProxyTraceListener,&#xD;&#xA;                     Microsoft.Practices.EnterpriseLibrary.Logging" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>
Oct 27, 2008 at 9:24 AM
Hi Chris,

I tried the steps in the documentation. and have repro you're error, also.
I copy and pasted this part
<add name="traceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging&#xD;&#xA;                     .TraceListeners.EntLibLoggingProxyTraceListener,&#xD;&#xA;                     Microsoft.Practices.EnterpriseLibrary.Logging" />
then the error appear when i run the app. Then i tried removing the other characters in the <add name> turning it to this.
<add name="traceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" />


Then the error never happened again,. I have run the app and made a log. This may sounds crazy but it worth giving a try.

Hope this helps.

.Kratos
Oct 27, 2008 at 4:07 PM
Cool!
 I give it a try in a few hours and let you know.  That always did look a bit suspicious to me, but I don't think I ever tried removing it.
Thanks a million!

Sep 21, 2009 at 9:34 AM

Thanks Kratos, Well spotted, its VS putting in hex chars