考虑在DLL以下代码:从汇编动态解析类型通过反射加载
public class ReceivingClass
{
private Assembly myAssembly;
private Type typeOfClass;
public ReceivingClass()
{
myAssembly = Assembly.LoadFile(@"E:\VSProjects\TestDynamicLinking\MyLib\bin\Debug\MyLib.dll");
//Can I use this type somehow to resolve the type in the below method?
typeOfClass = myAssembly.GetType("ExportedClass");
}
public bool ReceiveMethod(ExportedClass classobj)
{
return true;
}
}
因此,问题是,在上面的ReceiveMethod
,ExportedClass
是其在装配中定义的类,我动态加载到构造函数中。那么,我可以以某种方式解决ExportedClass
的类型,以便我不必使用dynamic
?