当通过methodInfo.Invoke调用方法时,如果抛出异常,它似乎不会传播到我的catch块.
object value; try { value = myMethod.Invoke(null,parameters);//program crashes with uncaught exception } catch { throw new Exception("Caught!");//never executed }
这个方法引发的特殊例外是KeyNotFoundException,但这应该不重要,因为我抓住了一切正确的东西?@H_301_5@
我从Visual Studio获得的特定错误消息是@H_301_5@
KeyNotFoundException was unhandled by user code
而通常消息会说@H_301_5@
KeyNotFoundException was unhandled
我可以让方法检查它们是否在那里,如果没有返回null,但是使用异常处理似乎更可取.有没有办法从反射的方法调用中传播异常?@H_301_5@