An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its depen

Apr 24, 2013 at 8:42 AM
Hi

We implemented a logger using the enterprise library. For some reason on most computers the new integration was successful. However, on one computer we keep getting the error mentioned: "An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

Background: The sln includes several projects which one of them contains the implementation of our Logger.
The Windows forms projects which we are trying to run contains a app.config file with the following entries:
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="EventLogLogger">
<listeners>
  <add name="EventLogLogger" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      source="Enterprise Library Logging" formatter="Text Formatter"
      log="" machineName="." traceOutputOptions="None" />
  <add name="FileLogger" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      footer="" formatter="Text Formatter" header="" rollSizeKB="5120"
      maxArchivedFiles="10" />
  <add name="EmailLogger" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      toAddress="to@example.com" fromAddress="from@example.com"
      subjectLineStarter="PRE" subjectLineEnder="SUF" formatter="Text Formatter" />
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      template="{timestamp}|{category}|{severity}|{win32ThreadId}|{message}{newline}"
      name="Text Formatter" />
</formatters>
<categorySources>
  <add switchValue="All" name="EventLogLogger">
    <listeners>
      <add name="EventLogLogger" />
    </listeners>
  </add>
  <add switchValue="All" name="FileLogger">
    <listeners>
      <add name="FileLogger" />
    </listeners>
  </add>
  <add switchValue="All" name="EmailLogger">
    <listeners>
      <add name="EmailLogger" />
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="All" name="All Events" />
  <notProcessed switchValue="All" name="Unprocessed Category">
    <listeners>
      <add name="FileLogger" />
    </listeners>
  </notProcessed>
  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <add name="FileLogger" />
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>

I've already tried to uninstall vs2012 and re install it.
I installed the VS2012 update 2 and no updates are necessary.
Windows 7
Microsoft Visual Studio Professional 2012 :
Version 11.0.60315.01 Update 2
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Professional

LightSwitch for Visual Studio 2012 04938-004-0033001-02162
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools 04938-004-0033001-02162
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012 04938-004-0033001-02162
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 04938-004-0033001-02162
Microsoft Visual Basic 2012

Visual C# 2012 04938-004-0033001-02162
Microsoft Visual C# 2012

Visual C++ 2012 04938-004-0033001-02162
Microsoft Visual C++ 2012

Visual F# 2012 04938-004-0033001-02162
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker 04938-004-0033001-02162
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools 04938-004-0033001-02162
Microsoft Visual Studio 2012 SharePoint Developer Tools

.NET Reflector Visual Studio Extension 8.0.2.313
Integrates .NET Reflector into Visual Studio to allow you to seamlessly debug into third-party code and assemblies, even if you don't have the source code for them.

Visit www.reflector.net for more information.

Copyright (c) 2009-2012 Red Gate Software Inc.

AlignAssignments 1.0
Command for aligning assignments.

AutoBraceComplete 1.0
auto brace complete

Color Theme Designer 1.0
Designer for creating new color themes

CustomDocWell 1.0
Provides configurable behavior for the document well in Visual Studio 2012.

JetBrains ReSharper 7.1.3 C# Edition build 7.1.3000.1964 on 2013-03-25T09:59:04
JetBrains ReSharper 7.1.3 package for Microsoft Visual Studio. For more information about ReSharper, visit http://www.jetbrains.com/resharper/. Copyright © 2003–2013 JetBrains, Inc.

Microsoft Enterprise Library Configuration Console 1.0
Launcher for the Microsoft Enterprise Library Configuration Console.

NuGet Package Manager 2.2.40116.9051
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

OptionsPageImpl 1.0
Information about my package

PowerCommands for Visual Studio 2010 1.0
A set of power commands for Visual Studio 2010

PreEmptive Analytics Visualizer 1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Quick Launch Tasks 1.0
Microsoft Quick LaunchTasks package adds accessibility and settings tasks to the Quick Launch tool.

Red Gate SQL Connect 1.1.3.485
Simple database development within Visual Studio

VSCommands11 11.0
VSCommands 11

Web Developer Tools 1.2.40308.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.
I'd appreciate any help you could offer.

Shay
Apr 24, 2013 at 9:43 AM
By the way
I DO NOT GET THE ERROR WHEN RUNNING ON RELEASE MODE

Thanks

Shay
Apr 25, 2013 at 4:36 AM
The exception occurs when the assembly information found at runtime does not match what was expected by the calling assembly (e.g. version or public key token does not match).

Since it is only occurring on one machine, I would suspect that there may be another version of Enterprise Library deployed on that machine (e.g. in the GAC). The quickest way to troubleshoot what is happening is to use the Assembly Binding Log Viewer to see the specific binding information. That should tell you what assembly is being located and you should be able to see how it differs from the expected version.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to