MSMQ Distributor issues with 2010 version

Topics: Exception Handling Application Block, Logging Application Block
May 31, 2013 at 10:59 PM
Edited May 31, 2013 at 11:00 PM
Hi,

I am using Enterprise Library 5.0 to log exceptions in MSMQ listener. This part is working correctly. I have also setup the MSMQ Distributor with logging configuration for File and a CustomTraceListener (this logs into our DB the way we want). But when I used the MSMQDistributor.exe from the EL bin folder, it gave the error:
Could not load file or assembly 'ELCustomTraceListener, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I then found out that the MSMQDistributor.exe in the EL bin folder is built in .Net 3.5. But with this exe, I was able to log in files or event logs.

Then I took the source code of MSMQ Distributor and built the 2010 .Net 4.0 version. I then copied it in the EL bin folder and re-installed the MSMQ Distributor service.

Now I keep getting this error:
An error occurred creating the configuration section handler for msmqDistributorSettings: Could not load file or assembly 'MsmqDistributor, Version=5.0.414.0, Culture=neutral' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

What am I missing here?

Here is the MsmqDistributor.exe.config:

<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="msmqDistributorSettings" type="Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.Configuration.MsmqDistributorSettings, MsmqDistributor"/>
</configSections>

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General Dist" logWarningsWhenNoCategoriesMatch="true">
<listeners>
  <!-- <add name="Formatted EventLog TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
    source="Enterprise Library Logging" formatter="Text Formatter" /> -->
  <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
    fileName="C:\Temp\Logging\ELQueueTrace.log" formatter="Text Formatter" />
  <!-- <add name="CustomDBTraceListener" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    type="ELCustomTraceListener.CustomDBTraceListener, ELCustomTraceListener, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
    traceOutputOptions="None" formatter="Text Formatter" /> -->
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
    template="Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}{newline}Priority: {priority}{newline}EventId: {eventid}{newline}Severity: {severity}{newline}Title:{title}{newline}Machine: {machine}{newline}App Domain: {appDomain}{newline}ProcessId: {processId}{newline}Process Name: {processName}{newline}Thread Name: {threadName}{newline}Win32 ThreadId:{win32ThreadId}{newline}Extended Properties: {dictionary({key} - {value}{newline})}"
    name="Text Formatter" />
</formatters>
<categorySources>
  <add switchValue="All" name="General Dist">
    <listeners>
      <!-- <add name="Formatted EventLog TraceListener" /> -->
      <add name="Flat File Trace Listener" />
       <!--  <add name="CustomDBTraceListener" /> -->
    </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" /> -->
      <add name="Flat File Trace Listener" />
      <!-- <add name="CustomDBTraceListener" /> -->
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>

<msmqDistributorSettings
msmqPath=".\Private$\EntLibQ"
queueTimerInterval="1000"
serviceName="GD Enterprise Library Queue Service" />
</configuration>
Jun 1, 2013 at 2:27 PM
What Enterprise Library assemblies is the newly Distributor service referencing? Perhaps the service is referencing unsigned versions of Enterprise Library assemblies? You could check the manifest to see what is being referenced:
ildasm MsmqDistributor.exe
You are going to want to reference the signed assemblies so you'll want to see:
.assembly extern Microsoft.Practices.EnterpriseLibrary.Common
{
  .publickeytoken = (31 BF 38 56 AD 36 4E 35 )                         // 1.8V.6N5
  .ver 5:0:414:0
}
Before building the Msmq Distributor Service change the references to point to the signed assemblies (and not use project references).

In general, to help track down "the located assembly's manifest definition does not match the assembly reference" errors you can use Fuslogvw.exe (Assembly Binding Log Viewer) to see assembly bind details and failures.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jun 3, 2013 at 11:25 PM
Thanks for the information. I was able to get rid of the error but now the MSMQ Distributor is ignoring the custom trace listener I added. The custom trace listener is in GAC so it should not have a problem accessing it. The Distributor is writing to the file but not in the DB through the custom trace listener. There are no errors in Event Log.

How do I find the problem?
Jun 4, 2013 at 2:48 AM
The config you posted is only configured to log to the Flat File Trace Listener (including errors). So, the custom trace listener is not configured (based on the posted configuration). Any errors should also go to the flat file. Do you see anything in the log file?

Also, you say that your custom trace listener is in the GAC so the assembly must be signed but the posted configuration does not contain the PublicKeyToken:
ELCustomTraceListener.CustomDBTraceListener, ELCustomTraceListener, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Try putting the PublicKeyToken in the config file.

As I mentioned Fuslogvw.exe (Assembly Binding Log Viewer) can be very helpful.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jun 11, 2014 at 10:23 PM
Hi,

I am facing the same issue here, could not find a solution yet. Could anyone can help me resolve it ASAP

I am trying to have a custom trace listener to log the details to database. if i build the project either in VS2010/2012, the MsmqDistributor Service is not starting at results in error.

MsmqDistributor.exe in 5.414 is not accepting a custom trace listener. We are migrating all VS2010 project o VS2012 projects. If i build the dll targeting 4.5 i receive the same error.

An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'XXXXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin\MsmqDistributor.exe.Config line 8)
BareMessage: An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly ‘XXXXXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I have also tried building the enterprise libary source, but its not solving the issue either.

Thanks.