How to determine if DLL is COM or .NET?

I guess one way to do it would be to try load the file with System.Reflection.Assembly.LoadFile() (more info). If you get a BadImageFormatException, it's not a valid .NET assembly. There's probably a neater way of doing this, but this should work.


To do this formally you could inspect the PE to find out more about what type of stuff each dll is exporting. There is a pretty interesting article on MSDN which talks about the structure. If you understand the setup, you can identify links to .Net (and thereby the lack indicating a pure COM dll).


Why not just call regsvr on all of them. If they register then ok, if not no big deal.

It is probably best though to write an installer that has the knowledge of which ones are which and does the right thing for each.

EDIT

If you are worried about "emitting errors", don't fret.

See this usage

You can suppress messages. (/s)

Tags:

.Net

Vb6