Archive for August, 2011

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.


Locating a Specific ResourceDictionary Within A MergedDictionary

August 5, 2011

Chances are you don’t really need to do this. In all probability you are latranating up the wrong woody perennial.

Answer this question: why do you want to locate a specific ResourceDictionary in the first place? Probably, like yours truly, you want to locate a specific resource within that particular ResourceDictionary. Like me you may have written some abomination like this:

return (DataTemplate)Application.Current.Resources.

Yes, enough to make you reach for the nearest brown paper bag isn’t it.

Good News: You don’t need to know the specific ResourceDictionary to locate your resource. And that’s because Dictionaries, including Merged Dictionaries are gigantic Hash Tables which means that all your resources are uniquely keyed within the Merged Dictionary itself. Which means you don’t need to know which are ResourceDictionary contains your resource. Which means you can simply write:

return (DataTemplate)Application.Current.Resources[key]

There. That feels better doesn’t it ?