dimanche 28 juin 2015

DefinedTypes property throws an error when an assembly is loaded from memory dynamically

I'm trying to load some of my project's assemblies dynamically.

When I load them via their file path like Assembly.LoadFile(path) I can get theirs defined types by calling GetTypes() method from loaded assembly.

var asm = Assembly.LoadFile(path);
var defienedTypes = asm.GetTypes(); //I've got all types without any error

But when I load them from memory like Assembly.Load(System.IO.File.ReadAllBytes(path)), I'm not able to retrieve defined types so calling GetTypes() method causes an error:

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

And LoaderExceptions property contains all defined types.





Aucun commentaire:

Enregistrer un commentaire