65.9K
CodeProject is changing. Read more.
Home

Retrieve the LoaderException Property for More Information…

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (2 votes)

Nov 29, 2012

Apache
viewsIcon

27827

Retrieve the LoaderException property for more information…

Here’s the exception I received today:

System.Reflection.ReflectionTypeLoadException. Unable to load one or more of the 
requested types. Retrieve the LoaderExceptions property for more information.

Isn’t it lovely? Do the authors think I have a little leprechaun sitting on the user machine and waiting for my command to retrieve the pot of gold the LoaderException property?

And if not, what do they expect my handling for oddball exceptions to be like? Perhaps something like:

catch (StrangeExceptionVarietyOne ex)
{
    Log(ex.ToString());
    Log(ex.FunkyPropertyOne);
}
catch (TotallyObscuredExceptionTwo ex)
{
    Log(ex.ToString());
    Log(ex.TotalObscurerAdditionalDataCollection);
}
catch (ReflectionTypeLoadException ex)
{
    Log(ex.ToString());
    foreach (var loaderEx in ex.LoaderExceptions) Log(loaderEx.ToString());
}
...

Not going to happen. A good exception should have everything in its ToString(). As in “for debugging purposes, AggregateException‘s ToString implementation outputs a string rendering all the contained exceptions“. This is a good exception. This is an exception I like to work with. Why can’t all exceptions be like that?