Thursday, January 12, 2012

An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.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)

I don’t understand why my client loves Enterprise Library. He is just mad about it. So people, I was trying to implement Enterprise Library in my application and suddenly I received the following error –
An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.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)
I know, I know, many of us get this type of error ample times for different assemblies and every time when we face it; we don’t have a concrete solution.
Alright so here I am presenting you a concrete solution which is good and fantastic and a real time saver.
To resolve above painful error we need to use – fuslogvw.exe tool – Assembly Binding Log Viewer.
Open Microsoft Visual Studio 2010 Command Prompt and type “fuslogvw” [without quotes]. This will open the fuslogvw tool. However the fuslog tool is not enabled by default. If you click on settings button you will find that, log is disabled by default.

To enable logging we need to add DWORD in registry. Type “regedit” in run window, to open registry editor. Navigate to HKLM\Software\Microsoft\Fusion. Add a two DWORDS namely ForceLog and LogResourcebinds and set their value to 1.



Close fuslogvw window if it is open and reopen it from visual studio command prompt. Ok, now we are here all set to see the error. Run your application again. When I ran my error and error was again received as stated above. Then I clicked on “Refresh” on fuslogvw window. List of all assemblies were listed as shown below –

I double clicked on the name of my DLL marked as yellow above and log details document opened. The error was quite obvious. Look at the red marked areas in below screenshot. Public key token in my web config was provided as 31bf3856ad364e35 where as DLL getting referenced was requiring public token as NULL. So I changed my Public Key token for logging DLL description in web config to NULL and problem solved.

Similarly fuslogvw.exe can be used for resolving other assembly specific errors. Hope this helps.
Cheers…
Happy Programming!!!

3 comments:

  1. Thanks. It helped me.

    ReplyDelete
  2. my 2010 cmd prompt says: 'fuslogvw' is not recognized as an internal or external command, operable program or batch file.

    ReplyDelete