添加引用 [英] Adding references
本文介绍了添加引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何以编程方式添加一个组件(DLL),如C#项目的参考?
我需要添加在运行时的参考。
How can I programmatically add an assembly (DLL) as reference in a C# project? I need to add a reference at run time.
考虑一下,如果我的项目使用另一个类库(DLL),然后我需要的DLL添加为引用在我的项目。我如何能做到在运行时
Consider if my project uses another class library (DLL) then I need to add that DLL as a reference in my project. How can I do that at run time?
推荐答案
也许你想获得的类型资讯从一类n在另一个.dll文件,然后的创建一个对象实例那类的。
Probably you want to get the type information from a class in another .dll, and then create an object instance of that class.
var lateBindingType = Type.GetType("Name.Of.The.Class,NameOfDll");
var instance = Activator.CreateInstance(lateBindingType);
在调用Type.GetType您使用的完全限定的类型名称。
In the call to Type.GetType you use the Fully Qualified Type Name.
这篇关于添加引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文