How to check dll is .net or non .net ? RRS feed

  • Question

  • I've a number of dlls in dir A, which contains a mix of .Net and non .Net dlls.


    How can I examine each one whether it's .Net dll programmatically?




    Wednesday, January 30, 2008 3:28 AM


  • .NET uses the exact same format as regular DLLs.  The only real difference is the stub code used to bootstrap the framework. 


    Programmatically determining whether a DLL is a .NET assembly or not is probably easiest if you just try to load it using Assembly.ReflectionOnlyLoad.  If it loads it then it is an assembly otherwise it isn't.  As slow as this is it is probably faster than trying to do something like detect the .NET stub code or looking for a .NET-only PE section.  I guess an alternative might also be to scan the import libraries for the DLL looking for any .NET System assemblies.  You'd have to parse part of the PE format for that though and it isn't easy.


    Michael Taylor - 1/30/08

    Wednesday, January 30, 2008 2:02 PM