Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

LoaderExceptions Property - .NET Framework

RSS
Modified on Tue, Apr 02, 2013, 4:03 PM by Administrator Categorized as ASP·NET MVC, ASP·NET Web Forms, ·Net Framework

Error Message

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

Resolution

Add a try/catch block to your code, similar to the following.

try 
{
    // Your existing code is here
}
catch (ReflectionTypeLoadException ex)
{
    StringBuilder sb = new StringBuilder();
    foreach (Exception exSub in ex.LoaderExceptions)
    {
        sb.AppendLine(exSub.Message);
        if (exSub is System.IO.FileNotFoundException)
        {
            var exFileNotFound = exSub as System.IO.FileNotFoundException;
            if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
            {
                sb.AppendLine("Fusion Log:");
                sb.AppendLine(exFileNotFound.FusionLog);
            }
        }
        sb.AppendLine();
    }
    Log("ERROR - " + sb.ToString());
    throw;
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.