Cannot resolve runtime error after registering Enterprise Library with GAC

I worked on registering Enterprise Library assemblies in the global assembly cache (GAC). I use version 5.0 of the Enterprise Library, which I signed with my own key, and I use assemblies in a number of .NET 4.0 applications.

After successfully registering Enterprise Library assemblies in the GAC, the application started with this message:

Cannot resolve type "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling". Check the spelling or type the full name of the type.

When I unregister Enterprise Library assemblies from the GAC, the application returns to normal.

What causes an application to fail when Enterprise Library assemblies are registered in the GAC?

+4
source share
1 answer

It took quite a bit of hunting to figure out what happened. As it turned out, the corporate library internally uses partial names for the dynamic type of loading. In this case, the corporate library tries to dynamically load Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter dynamically because it appears in the configuration file.

To bypass partial name references at run time, simply enter the qualifyAssembly element in the configuration file (see the <qualifyAssembly> Element in the MSDN documentation).

In my case, all I had to enter was a record:

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyAssembly partialName="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" fullName="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </assemblyBinding> </runtime> 
+7
source

All Articles