如何动态加载程序集?
我需要动态的调用未知程序集中的已知接口,如何在.NET中实现?
我在VB6中是这样实现的
dim objI as iMyinterface
set objI=createobject("MyObject.MyClass")
objI.dosomething
我们使用这种方法来实现可扩展算法插件,但是在.NET中不知道该如何实现?
如能赐教 不胜感谢
分数不够 可以再加
我的mail:bucher_j@bigfoot.com
问题点数:100、回复次数:1Top
1 楼TheAres(班门斧)回复于 2002-11-26 13:38:19 得分 100
Example:
' load the assembly
Dim assembly1 As System.Reflection.Assembly = Assembly.LoadFrom("SpecContro
ls.DLL")
' get the type
Dim t As Type = assembly1.GetType("MyControls.MyControl")
' create an instance and add it.
'
Dim c As Control = CType(Activator.CreateInstance(t), Control)
parent.Controls.Add(c)
Also, have a look at:
动态载入装配件,派生类与基类的转换时的问题
http://expert.csdn.net/Expert/TopicView3.asp?id=1094557Top




