How to enumerate classes from a DLL

  • Thread starter Thread starter bz
  • Start date Start date
B

bz

Hi,
I need to create a sort of dll inspector, for NET, and I need to
receive the filename of a dll, then check if it is a NET dll and if
so, enumerate all classes defined in it
I know how to enumerate all types from an assemble, with

Assembly assembly;
foreach(Type type in assembly.GetTypes()) {

but I don't know how to find if the dll is actually a NET dll and how
to create a variable of type Assembly from dll filename

Thanks
 
bz said:
Hi,
I need to create a sort of dll inspector, for NET, and I need to
receive the filename of a dll, then check if it is a NET dll and if
so, enumerate all classes defined in it
I know how to enumerate all types from an assemble, with

Assembly assembly;
foreach(Type type in assembly.GetTypes()) {

but I don't know how to find if the dll is actually a NET dll and how
to create a variable of type Assembly from dll filename

Thanks

Assembly.LoadFile("c:\path\filename.dll") will return an assembly for you to
call GetTypes. I'm not sure if there is a way other than trapping an
exception on the call to LoadFile (BadImageFormatException).

Mike
 
Back
Top