Dll文件中有一个接口,我只想通过反射来获取接口变量 [英] There is a interface in a Dll file ,I just want to get the interface variable by use reflection

查看:128
本文介绍了Dll文件中有一个接口,我只想通过反射来获取接口变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么办?

在Dll文件中,有一个类似"InterfaceA"的接口,我想通过使用反射在我的代码中得到类似的东西,
InterfaceA a;

谢谢

How can i do it?

In a Dll file ,there is a interface like "InterfaceA" ,I want to get something like this in my code by using reflection,
InterfaceA a;

Thanks

推荐答案

谢谢您的提问.您可以按照下面的代码.
Thank you for your question. You can follow the bellow code.
using System.Reflection;


Assembly a = Assembly.LoadFrom("MyDll.dll");

Type type;
type = a.GetType().GetInterface("InterfaceA");
// type.Name;


详细信息: http://msdn.microsoft.com/en-us/library/tcctb9t8.aspx [^ ]


谢谢,
马蒙


More Information:http://msdn.microsoft.com/en-us/library/tcctb9t8.aspx[^]


Thanks,
Mamun


这篇关于Dll文件中有一个接口,我只想通过反射来获取接口变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆