如何确定DLL是COM或.NET?DLL、COM、NET

2023-09-04 08:10:42 作者:英俊潇洒

我有一个更新程序,从服务器拉文件有混合VB6的dll和.NET的DLL在一个目录。如何确定是否一个dll是一个COM一个? (这样我就可以在更新程序调用REGSVR32吧)

i have an updater program, the pulled files from server has mixed vb6 dll and .net dll in one directory. how to determine if a dll is a COM one? (so i can invoke regsvr32 to it from the updater program)

推荐答案

我想这样做是尝试装入System.Reflection.Assembly.LoadFile文件()的一种方式。如果你得到一个BadImageFormatException,这不是一个有效的.NET程序集。有可能是这样做的更合适的方法,但这应该工作。

I guess one way to do it would be to try load the file with System.Reflection.Assembly.LoadFile(). 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.

http://msdn.microsoft.com/en-us/library/b61s44e8.aspx

 
精彩推荐
图片推荐