Get Types in assembly (error: System.Reflection.ReflectionTypeLoadException)
I'm receiving an Exception of type "Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information." with the following 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 defined in each assembly but it seems that it cannot be generated.
I already performed all typical procedures related to wrong assembly creating by deleting dll´s, clean solution, reload solution, etc but nothing happened.
I would like to request ideas in order to solve this problem by finding a way to retrieve more information of the error, or find which assembly is generating problems or something like that. The current exception message is so vague to realize which is the problem.
ps: additional info, when I ru开发者_开发百科n the rebuild action all process are correctly generated with no errors.
The error message says everything you need, really:
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
}
}
If you use the Entity Framework, check if version in Web.Config is the same referenced in your project.
Was the DLL created by you? Which framework are you targeting?
I've faced this problem just now. Even compiling my external libs with framework 3.5 (that uses CLR2), the DLL coudn't be imported. The error was the same as yours. I've solved my problem rebuilding my libs targeting framework 3.0 and seems to work now. I'm leaving my dlls in Plugins folder with no problems.
There are lots of similar problems in Unity forums.
Maybe you have the solution already, but this can help anyone who needs it in the future (like I needed).
Best Regards!
精彩评论