如何判断一个DLL是否可以访问? [英] How can I tell if a DLL is ComVisible?
本文介绍了如何判断一个DLL是否可以访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可能会将ComVisible属性设置为true或不可能的DLL。我不知道它是如何构建的,还是什么属性?我知道的是,它是一个.Net DLL。简单的说,如何知道Com是否可见?
I have a DLL that may or may not have its ComVisible attribute set to true. I'm not sure how it was built, or with what attributes? All I know is that it's a .Net DLL. Simply put, how can I tell if it is Com Visible?
如果这是重复的话,抱歉。所有关于此返回结果的搜索结果显示了如何使一个DLL ComVisible。我知道如何做到这一点。
Sorry if this is a duplicate. All of my searches about this return results that show how to make a DLL ComVisible. I know how to do that.
推荐答案
你可以查看 ComVisibleAttribute :
private static bool IsComVisible(string assemblyPath)
{
var assembly = Assembly.LoadFile(assemblyPath);
var attributes = assembly.GetCustomAttributes(typeof(ComVisibleAttribute), false);
if (attributes.Length > 0)
{
return ((ComVisibleAttribute)attributes[0]).Value;
}
return false;
}
这篇关于如何判断一个DLL是否可以访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文