Search code examples
c#debuggingunity-containerfileloadexception

FileLoadException when using Microsoft Unity configuration


A FileLoadException when using Unity generally means that a type has been configured for that cannot be loaded because the assembly has not been reference by the project.

How can I find out what type is trying to be resolved so that a reference can be added to the project (or remove an unused type that is configured in the app.config).


Solution

  • If you turn on the debug exceptions (Debug>Exceptions ... Ctrl+D, E) and turn on the System.IO.FileLoadException

    When I did this I was able to hover over the type that was being resolved which pointed at an extra type that was specified in the app.config file.

    It failed in TypeResolverImpl.SearchAssemblies(string typeNameOrAlias)

    If you hover over the typeNameOrAlias variable you'll see the type it is resolving.