This is the way System.Reflection operates. .Net 4.5 seem to have gained the ability to unwrap and rethrow the inner exception without losing its context: http://stackoverflow.com/questions/57383/in-c-how-can-i-rethrow-innerexception-without-losing-stack-trace
I wonder if NHibernate should eventually make use of that ability. But for now it doesn't. It can of course be debated if catching exceptions with such detail should be done at all or if some alternative method should be used. /Oskar 2016-07-29 11:35 GMT+01:00 Mark Perry <[email protected]>: > Given the following: > > public class Customer : EntityBase{ > public virtual string Name {get;set;} > //Snip > > public void TestError(){ > throw new Exception("Test"); > } > } > > When I load this entity using NH and call the "TestError" method. Instead > of getting that Exception I am getting it inside another one nested in the > InnerExecptionProperty. > > The actual exception is: > > System.Reflection.TargetInvocationException > "{"Exception has been thrown by the target of an invocation."}" > > at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] > arguments, Signature sig, Boolean constructor) > at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, > Object[] parameters, Object[] arguments) > at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags > invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) > at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) > at NHibernate.Proxy.DynamicProxy.InvocationInfo.InvokeMethodOnTarget() > at > NHibernate.Intercept.DefaultDynamicLazyFieldInterceptor.Intercept(InvocationInfo > info) > at CustomerProxy.TestError() > > > Why is this happening? I don't understand why my exception is being > wrapped inside another one from the DynamicProxy. > > Thanks, Mark > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
