我想像这样从WinForm中的另一个程序集调用方法
private void loadToolStripMenuItem_Click(object sender, EventArgs e){
Thread thread = new Thread(() =>
{
string assemblyPath = "PluginForSnake.dll";
AppDomain domain = AppDomain.CreateDomain("MyNewDomain");
ObjectHandle handle = domain.CreateInstanceFrom(assemblyPath, "PluginForSnake.Save");
object obj = handle.Unwrap();
MessageBox.Show("found");
if (RemotingServices.IsTransparentProxy(obj)){
Type type = obj.GetType();
object[] param = new object[] { _snake, _food };
MethodInfo saveGame = type.GetMethod("saveGame");
saveGame.Invoke(obj, param);
}
});
thread.IsBackground = true;
thread.Start();
}但是我在调用行中得到了这个异常
System.Reflection.TargetInvocationException类型的未处理异常发生在mscorlib.dll中
https://stackoverflow.com/questions/40739341
复制相似问题