AppDomain, ResolveEventArgs not marked as serializable

Topics: Exception Handling Application Block
Mar 12, 2012 at 10:28 AM

Hello,

I'm trying to use Enterprise Library in a c# project that is load using a createDomain. Problem happens when trying to handle exception. 

this is the exception : Type 'System.ResolveEventArgs' in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName) in C:\Users\mathias.herbaux\Documents\EntLib50Src\Blocks\ExceptionHandling\Src\ExceptionHandling\ExceptionPolicy.cs:line 57
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, Exception& exceptionToThrow) in C:\Users\mathias.herbaux\Documents\EntLib50Src\Blocks\ExceptionHandling\Src\ExceptionHandling\ExceptionPolicy.cs:line 111

To be sure it was not a configuration error, i tried with a console app with the same exception and logging configuration and the same assemblies, all works fine. It seems that using it in a different domain makes it crash. Does anyone has already experience this issue ?

Thanks

Mar 13, 2012 at 1:20 AM

It sounds like an AssemblyResolve event is crossing (or attempting to cross) Application Domains.  The exception is raised because the ResolveEventArgs is not serializable.  I would try to run the Assembly Binding Log Viewer to see what assemblies are failing.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Mar 13, 2012 at 7:24 AM

Finally i found what was wrong, and it was clearly not EL ! In my first application (real one), handling exception didn't worked, but there was not exceptions. So i thought it was was a silent exception. Then i get the EL sources to inspect whats was going on. With the sources i made a terrible mistake, referencing in a test application just 2 of the project (Common and ExceptionHandling). Finally i tried again with assemblies that are installed and all worked fine, the problem is that there was no exception thrown and make me go in a wrong way.

Thx for the reply