使用 InnerException 就可以显示出反射调用里头的错误信息。

voidfn(intn) { if(n>=10) return; thrownewArgumentException("参数必须大于10"); }

Typetype=typeof(Program); objectinstance=Activator.CreateInstance(type); MethodInfomi=type.GetMethod("fn",BindingFlags.NonPublic|BindingFlags.Instance); try{ mi.Invoke(instance,newobject[]{null}); } catch(TargetInvocationExceptiontargetEx) { if(targetEx.InnerException!=null) { throwtargetEx.InnerException; } }