In assembly, get Types (error: System.Reflection.ReflectionTypeLoadException) c# entity-framework system.reflection


I'm getting a type Exception "Exception Information: System.Reflection. Unable to load one or more of the required types, according to the ReflectionTypeLoadException. For further details, get the LoaderExceptions field "with this particular code:

public IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true)
        foreach(var a in assemblies)
            foreach (var t in a.GetTypes())

I need to get the types that are specified in each assembly, but it doesn't appear possible to produce them.

I previously deleted dll files, cleaned the solution, reloaded the solution, and other standard operations connected to improper assembly creation, but nothing changed.

I'm looking for suggestions on how to resolve this issue, such as how to identify the problematic assembly or how to get further information about the mistake. The existing error message is so ambiguous that it is difficult to identify the issue.

I really appreciate it. P.S. Additional information: When I do the rebuild operation, every process is produced appropriately and without any issues.

5/22/2011 7:26:30 AM

Accepted Answer

Really, the error message is all you need to know:

try {
    // your code
} catch (ReflectionTypeLoadException ex) {
    // now look at ex.LoaderExceptions - this is an Exception[], so:
    foreach(Exception inner in ex.LoaderExceptions) {
        // write details of "inner", in particular inner.Message
5/22/2011 7:48:35 AM

Popular Answer


Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow