The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception

Topics: Exception Handling Application Block
Jul 11, 2008 at 7:03 AM

{System.TypeInitializationException: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy..cctor()

=== Pre-bind state information ===
LOG: User = SUMERU\suresh
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///E:/CompleteCrossTab/VS2005/TestExceptionClient/
LOG: Initial PrivatePath = E:\CompleteCrossTab\VS2005\TestExceptionClient\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\CompleteCrossTab\VS2005\TestExceptionClient\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=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/testexceptionclient/5f88b900/23c3c2b9/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/testexceptionclient/5f88b900/23c3c2b9/Microsoft.Practices.EnterpriseLibrary.Common/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
LOG: Attempting download of new URL file:///E:/CompleteCrossTab/VS2005/TestExceptionClient/bin/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

   --- End of inner exception stack trace ---
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, Exception& exceptionToThrow)
   at _Default.Button1_Click(Object sender, EventArgs e) in e:\CompleteCrossTab\VS2005\TestExceptionClient\Default.aspx.cs:line 75}


Please help me with the above the situation. your timely help would be of much use for me....

Jul 11, 2008 at 2:57 PM
Hi,

There seems to be a mismatch of assembly versions in your app. The fusion log is stating that the major version number for the Common assembly it found does not match 3.1.0.0...
Make sure the version for all your assemblies is correct.

Fernando
Jul 14, 2008 at 5:27 AM
ya it works fine with me now.. thanks for your help.. Could you please help me in developing a customized wrap handler .. sample appln would be of much
help to me..


Suresh
Jul 14, 2008 at 5:08 PM
Hi,

You can take a look at the existing wrap handler for an example. In fact you could clone it in your project and change it to suit your needs.

Fernando


tell2suresh wrote:
ya it works fine with me now.. thanks for your help.. Could you please help me in developing a customized wrap handler .. sample appln would be of much
help to me..


Suresh


Jul 15, 2008 at 5:17 AM
I know the steps to create a wrap handler through configuration but i do not have any sample application which gives me a clear picture of creating a wrap handler
(customized)..i am not aware of what are the methods i have to customize etc... so a sample application which has custom wrap handler implemented will be of much help
to me..

Suresh
Jul 15, 2008 at 1:33 PM
Hi,

What I meant is that the implementation for the existing WrapExceptionHandler is a sample of what you'd need to do. You also have a sample in the Exception Handling QuickStart app, and some information in http://msdn.microsoft.com/en-us/library/cc511781.aspx. You may also want to look at Tom's SqlExceptionWrapHandler from EntlibContrib, which implements full design time support.

Fernando



tell2suresh wrote:
I know the steps to create a wrap handler through configuration but i do not have any sample application which gives me a clear picture of creating a wrap handler
(customized)..i am not aware of what are the methods i have to customize etc... so a sample application which has custom wrap handler implemented will be of much help
to me..

Suresh


Jul 15, 2008 at 2:40 PM
Thanks a lot Fernando.. I will look into the code and i will get back to you if i have any doubts.. Thanks for your help.

Also i am facing this problem in the enterprise blocks.. i.e when i create all the blocks in one application and try to copy the App.config to other application it is
throwing errors. Saying it cannot load the assembly while creating configurations... is there any relation with the public key token of the dlls..? or we have to create the
blocks every time we move it to another applicaiton.. like test to development to production..

Suresh.
Jul 15, 2008 at 3:30 PM
It's hard to tell without looking at the actual error message. There are a few recurring issues regarding configuration and assembly versions; have you tried searching for your error message in this discussion list?

Fernando

Also i am facing this problem in the enterprise blocks.. i.e when i create all the blocks in one application and try to copy the App.config to other application it is
throwing errors. Saying it cannot load the assembly while creating configurations... is there any relation with the public key token of the dlls..? or we have to create the
blocks every time we move it to another applicaiton.. like test to development to production..


Aug 25, 2008 at 2:17 PM
I had this problem : The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception when I upgraded Enterprise library to 3.1.
It was solved by addition of publickeytoken everywhere in the application config file. Earlier it was null : e.g <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />