I've inherited a .NET application that pulls together about 100 dlls built by two teams or purchased from vendors. I would like to quickly identify whether a given dll is a .NET assembly or a COM component. I realize that I could just invoke ildasm on each dll individually and make a note if the dll does not have a valid CLR header, but this approach seems clumsy and difficult to automate.
.net – Identifying COM components in a .NET application
netwindows
Related Topic
- C# – .NET String.Format() to add commas in thousands place for a number
- .net – Difference between decimal, float and double in .NET
- C# – How to get the application’s path in a .NET console application
- C# – Reading settings from app.config or web.config in .NET
- C# – How to force the .NET application to run as administrator
- C# – How to turn a C# object into a JSON string in .NET
- .net – the difference between .NET Core and .NET Standard Class Library project types
Best Answer
If you want to approach from the COM side, testing for COM objects in a DLL boils down to looking for an export named "DllGetClassObject". This is because an in-proc COM object is accessed by the COM runtime by calling DllGetClassObject() on that DLL.
You could do this from a batch file using DUMPBIN.EXE which comes with Visual Studio as follows:
The above command line will produce one line of text if it is an unmanaged DLL that contains COM objects, or zero bytes of output otherwise.
You could do this programmatically by loading each DLL and try to do a GetProcAddress() on that entry point. Here is a tested and working C# command line program that uses this technique: