我加载了一个程序集并执行了这样的方法:
Assembly.LoadFrom("C:\\ConsoleApp1.exe");
Type UpdaterType = assembly.GetType("ThorUpdaters.ThorUpdater");
object instance = Activator.CreateInstance(UpdaterType);
int ReturnCode = (int) UpdaterType.InvokeMember("StartUpdater", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, instance, null);
Logger.Log($"ReturnCode: {ReturnCode}");
如果代码成功完成,我会看到返回码。但是,如果我在调用的方法中抛出异常,调用者似乎就永远坐在那里等待返回值。
有什么建议吗?