C#反射怎么获取一个程序集的所有非托管DLL
1个回答
展开全部
assembly asm = assembly.loadfile("程序集路径");
foreach (type t in asm.gettypes())
{
foreach (methodinfo mi in t.getmethods(bindingflags.static | bindingflags.public))
{
foreach (object obj in mi.getcustomattributes(false))
{
if (obj is dllimportattribute)
console.writeline(((dllimportattribute)obj).value);
}
}
}
foreach (type t in asm.gettypes())
{
foreach (methodinfo mi in t.getmethods(bindingflags.static | bindingflags.public))
{
foreach (object obj in mi.getcustomattributes(false))
{
if (obj is dllimportattribute)
console.writeline(((dllimportattribute)obj).value);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询