lundi 29 juillet 2019

Use reflection to get types from dll

I'm trying to get types from a dll that contains other dll references. How can I just ignore the referenced dlls?

I am new to work with Reflection and .dll files. I want to get types existing in the dll but I get this exception "System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified." After looking in the code, I find that the used dll file references/uses other dll files which I do not have.

How can I do to just get the types inside my dll file and ignore the types inside the referenced files?

byte[] data = System.IO.File.ReadAllBytes("filePath");
Assembly assembly = Assembly.Load(data);
var types = assembly.GetTypes();

I expect that I can get the content of the dll (classes, methods, structs, etc)





Aucun commentaire:

Enregistrer un commentaire