try
{
var types = Assembly.LoadFrom((new FileInfo(file)).FullName).GetTypes();
if (types == null)
continue;
foreach (var t in types)
{
var intef = t.GetInterface("GPLib.IParaSelector");
if (intef != null)
{
var tmp = Activator.CreateInstance(t);
var obj = tmp as IParaSelector;//这里居然为null
if (obj != null) ParaTypes.Add(obj.TypeGUID, t);
}
}
}
C#3。5
先查询的接口,然后才转换的,居然会有问题!
有人遇到过吗?如何处理?
必须调用实现接口的类型或者反射调用工厂方法
vb.net?是C#的话我这里的方法好象是
var intef = t.GreateInterface("GPLib.IParaSelector");