Enterprise Lib 4.0 Could not load assembly.

Topics: Enterprise Library Core, General discussion
Jun 2, 2008 at 7:39 PM
An error occurred creating the configuration section handler for enterpriseLibrary.ConfigurationSource: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

I'm getting the error listed above anytime I use any code in my application from Enterprise Lib 4.0.  Has anyone else experienced this?  Not sure what the possible solutions are...

Pre-bind state info:

=== Pre-bind state information ===
LOG: User = POINTYHAT1\Scott
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Common, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Appbase = file:///C:/Source/DunDat/DunDat/
LOG: Initial PrivatePath = C:\Source\DunDat\DunDat\bin
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Source\DunDat\DunDat\web.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Microsoft.Practices.EnterpriseLibrary.Common, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/4d03632e/eb2353f6/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/4d03632e/eb2353f6/Microsoft.Practices.EnterpriseLibrary.Common/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
LOG: Attempting download of new URL file:///C:/Source/DunDat/DunDat/bin/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Jun 4, 2008 at 3:22 AM
Yes I had this problem a couple of days ago:
(this assumes VS 08 and EL 4.0 but if that's not you, check it out anyway)

When you install enterprise library it installs with compiled and signed assemblies located in the c:\program files\something something ... and if you opted to have it build from source
you get a separate set of unsigned assemblies in the c:\entlib4\something something..  The problem is that by default, the configuration utility will use the signed ones, but you probably added the reference by browsing to c:\entlib4 ...

Below I've included a link that explains it a hundred times better than I ever could (Tom Hollander FTW) but here is a quick summation if you want to give it a shot.

1.  left click once on your web site solution item in your solution explorer.
2.  now click on the properties tab (right clicking on the solution item and selecting properties does not work)
 ... if you dont have a properties tab on your IDE you'll need to turn it on in the menu or whatnot...
3.  There should be a property called EnterpriseLibraryConfigurationSet.  And it will be set to {machine default} by default. (this points to the signed assemblies NOT in c:\entlib4)
4.  Click the drop down and choose "EntLib4" instead.  (this will match up with the
5.  rebuild --- should work.

And here is the aforementioned righteous link: