2 回答
TA贡献1890条经验 获得超9个赞
Assembly.LoadFrom("assemblyName").GetTypes();
Assembly.Load("assemblyName").GetTypes();
遍历, 再通过Type.GetInterface("```"),如果结果不为null,那就说明找到了
再Activator.CreateInstance(“”)即可
还是写段代码吧:
foreach(Type t in Assembly.Load("MyAssemblyName").GetTypes())
{
if(t.GetInterface("IYourInterface")!=null)
{
IYourInterface=(IYourInterface)Activator.CreateInstance(t);
````
}
}
foreach(Type t in Assembly.Load("MyAssemblyName").GetTypes())
{
if(t.GetInterface("IYourInterface")!=null)
{
IYourInterface=(IYourInterface)Activator.CreateInstance(t);
````
}
}
hoho就这样
- 2 回答
- 0 关注
- 538 浏览
添加回答
举报