Posts Tagged ‘Norbert’

Enterprise Library ExceptionManager.Current Throws ‘Exception Thrown By Target Of Invocation’ After Renaming Namespace

December 14, 2011

The problem, dear Tadpolers, is that the ExceptionManager cannot load because the type of the Exception no longer exists because the namespace that it originally lived in has just been renamed. Therefore the ExceptionManager cannot load its handlers.

In my case I had a ReplaceHandler:
add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" exceptionMessage="Data Access Error. Please notify Service Desk." exceptionMessageResourceType="" replaceExceptionType="Common.RepositoryException, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

But then I renamed The Namespace ‘Common’ to Norbert.Common, so the next time the ExceptionManager tried to load its ReplaceHandler it could not find the namespace Common or the type Common.RepositoryException, so its threw a TargetInvocationException.
I had to go through my app.config and update all instances of Common.RepositoryException to Norbert.RepositoryException like so:

add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" exceptionMessage="Data Access Error. Please notify Service Desk." exceptionMessageResourceType="" replaceExceptionType="Norbert.Common.RepositoryException, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

Sweet As..

Advertisements

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler Cannot Be Resolved

August 30, 2011

Having got the error in the title you may also have noticed
EnterpriseLibraryContainer.Current throws an ArgumentException.

The reason for this is that you are missing a reference to the ExceptionHandler.Logging dll
i.e. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll

…And/Or you have not copied that dll to the bin directory of your solution.

You wouldn’t forget something as simple as that, would you ?

I certainly didn’t.
And neither did NORBERT my invisible Aardvark snowboarding companion.

And that full error text for your unmitigated reading pleasure:

‘Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ cannot be resolved. Please verify the spelling is correct or that the full type name is provided.