原文:C#获取C# DLL中的指定接口的所有实现实例 - qq_19759475的博客 - CSDN博客
public static List<T> CreateTarInterface<T>(string dllpath)
{
List<T> rs = new List<T>();
var dlllll = Assembly.Load(dllpath);
foreach (var item in dlllll.GetTypes())
{
object objType = dlllll.CreateInstance(item.Namespace + "." + item.Name);
if (typeof(T).IsAssignableFrom(objType.GetType()))
rs.Add((T)objType);
}
return rs;
}
原文地址:https://www.cnblogs.com/lonelyxmas/p/10880061.html
时间: 2024-10-06 20:08:32