MethodCaller bug?

MethodCaller bug?

Old forum URL: forums.lhotka.net/forums/t/5411.aspx


GlennMiller posted on Tuesday, September 16, 2008

Hi,

We're trying out Csla CE and have found what we think is a problem in CslaCE.MethodCaller.CallMethod. The catch there throws a new CallMethodException, passing ex..InnerException. As noted in this thread, http://forums.lhotka.net/forums/thread/21707.aspx, this is how Rocky got to the exception in Csla 3.0. The thread points out that the exception of interest is wrapped in a reflection exception, so accessing the InnerException property gets back to the original exception.

However, we're noticing in all our tests that if an exception happens on the "back" side of the DataPortal methods (like DataPortal_Fetch), the exception that ends up in MethodCaller.CallMethod is *not* wrapped. In fact the InnerException property is null, so Csla crashes later in CallMethodException's constructor.

We're assuming that the "ce-ifying" of the code removed the reflection wrapper, so we fixed the problem by changing CallMethod to pass on the exception itself, not its innerexception. Sound right?

lawrencek replied on Tuesday, September 23, 2008

Please post this also.  Also thanks for working on the data portal calls..

I have not been using them and have been tring to fill them out as much a CE will allow.

GlennMiller replied on Tuesday, September 30, 2008

Here's the method from MethodCaller.cs. We commented out the InnerException as shown.

///
/// Uses reflection to dynamically invoke a method,
/// throwing an exception if it is not
/// implemented on the target object.
///
public static object CallMethod(
object obj, MethodInfo info, params object[] parameters)
{
// call a private method on the object
object result;
try
{
result = info.Invoke(obj, parameters);
}
catch (Exception e)
{
throw new Csla.Server.CallMethodException(
info.Name + " " + Resources.MethodCallFailed, e/*.InnerException*/);
}
return result;
}

Copyright (c) Marimer LLC