如何确定DLL是COM或.NET? [英] How to determine if DLL is COM or .NET?
问题描述
我有一个更新程序,从服务器拉文件有混合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.
<一个href="http://msdn.microsoft.com/en-us/library/b61s44e8.aspx">http://msdn.microsoft.com/en-us/library/b61s44e8.aspx
这篇关于如何确定DLL是COM或.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!