I want to call method from another assembly in WinForm like this
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();
}
But im getting this exception at Invoke line
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll