从应用程序中的Dll主机识别.Net Dll [英] To Identify .Net Dll's from host of Dll's in Application
问题描述
大家好,
在我的应用程序中,我有大约600个二进制文件,即COM DLL,Win32 Dll,OCX& .Net Dll',但我需要识别它们中的.NetDll',在这个上下文中让我知道,与其他Dll相比,.Net Dll'/ Assemblies的区别特征是什么?
例如,我们能够通过以下属性识别COM Dll,即(InProcServer)DllRegisterServer,但我不能同样弄清楚,.NetDll / Assemblies。
因为我是.Net的新手,我需要一些帮助才能解决上述问题。
详情:
VS 2008 IDE,Window 7 O / S,(。Net 4.5)
问候,
Vishal_K89
Hi All,
In my Application, I have about 600 binaries viz., COM DLL, Win32 Dll, OCX & .Net Dll''s, but I need to identify the .NetDll''s among them, In this context let me know, what is the distinguishing feature of .Net Dll''s/Assemblies compared to other Dll''s ?
For Example we are able to identify COM Dll''s by presence of following attribute viz., (InProcServer) DllRegisterServer, but I wasn''t able to similarly figure out, .NetDll/Assemblies.
Since, I am new to .Net , I need some assitance in resolving the above issue.
Details:
VS 2008 IDE , Window 7 O/S,(.Net 4.5)
With Regards,
Vishal_K89
推荐答案
尝试使用Reflection打开所有DLL。当它失败时,它不是.NET DLL。这正是我在这种情况下所做的,它有效。
-SA
Try to open all DLLs with Reflection. When it fails, it''s not a .NET DLL. This is exactly what I did in such situation, it works.
—SA
非以编程方式,您可以右键单击dll&选择属性以打开属性对话框。在版本选项卡中,如果您在项目名称列表框下看到程序集版本,则它是一个托管dll。您还可以使用Assembly类以编程方式确定是否管理给定的dll。
Non programmatically you can right click the dll & select properties to open properties dialog. In the version tab if you see Assembly Version under Item name listbox then it''s a managed dll. You can also use Assembly class to programmatically determine whether a given dll is managed or not.
bool IsManaged(string path)
{
try
{
Assembly.ReflectionOnlyLoadFrom(path);
return true;
}
catch(BadImageFormatException e)
{
// Code to print the error
}
return false;
}
问候,
Regards,
这篇关于从应用程序中的Dll主机识别.Net Dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!