Index was outside the bounds of the array

Index was outside the bounds of the array

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


halcwb posted on Tuesday, March 23, 2010

My code throws the below mentioned error when a method is called to update a child. The child_update method is never reached. The problem occurs in the Csla.Reflection.MethodCaller. When the following code is reached:        

result = methodHandle.DynamicMethod(obj, inParams); (line 357). The exception is thrown.

The child is created using CodeSmith template v2.0.

{"Index was outside the bounds of the array."}
    [System.IndexOutOfRangeException]: {"Index was outside the bounds of the array."}
    _className: null
    _data: {System.Collections.ListDictionaryInternal}
    _dynamicMethods: {object[1]}
    _exceptionMethod: null
    _exceptionMethodString: null
    _helpURL: null
    _HResult: -2146233080
    _innerException: null
    _message: "Index was outside the bounds of the array."
    _remoteStackIndex: 0
    _remoteStackTraceString: null
    _source: null
    _stackTrace: {sbyte[48]}
    _stackTraceString: null
    _xcode: -532459699
    _xptrs: 0
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    HResult: -2146233080
    InnerException: null
    IsTransient: false
    Message: "Index was outside the bounds of the array."
    Source: "Csla"
    StackTrace: "   at dm(Object , Object[] )\r\n   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\\Visual Studio Projects\\csla\\Source\\cslacs\\Csla\\Reflection\\MethodCaller.cs:line 357"
    TargetSite: {System.Object dm(System.Object, System.Object[])}

I use VS2008 SP1 and CSLA 3.8 framework with CodeSmith templates version 2.0

I hope this is some known problem or mistake on my side, otherwise I am severely stuck.

skagen00 replied on Tuesday, March 23, 2010

Just throwing a total guess out there - as I don't believe I've ever used DynamicMethod, but your "inParams" - does this represent the parameters needed for the method? Do you have a sufficient number of parameters for your method call? (i.e. is it trying to look for a parameter and finding that the parameter array is a day late and a parameter short?)

halcwb replied on Wednesday, March 24, 2010

Dear Skagen,

Thanks for the effort, but to make things clear. The problem occurs outside the scope of my code. The DynamicMethod is an internal function of the CSLA framework to invoke late bound methods on business objects. I did look at the parameters of this method, but they seemed fine. It contains two objects, one being the child on which the portal update method should be invoked, the other being the connection to the database. At least, this is my understanding up till know.

I do not use any non public method of the CSLA framework. As a matter of fact all business objects have been generated by CodeSmith templates. I use the partial classes to supplement my own code.

But again, I might be missing something obvious, I worked with previous versions of CSLA up to 2.0, so 3.8 is quite new to me.

Regards -- Casper

RockfordLhotka replied on Wednesday, March 24, 2010

Can you please provide the stack trace from the exception? The exception itself isn't enough information to tell where the error occurred in the code.

halcwb replied on Wednesday, March 24, 2010

Thank you for looking into this:

Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:


Line 355:      try
Line 356:      {
Line 357:        result = methodHandle.DynamicMethod(obj, inParams);
Line 358:      }
Line 359:      catch (Exception ex)
 

Source File: C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs    Line: 357

Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
   dm(Object , Object[] ) +100
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:357

[CallMethodException: Child_Insert method call failed]
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:361
   Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:270
   Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:86
   Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:201

[DataPortalException: ChildDataPortal.Update failed on the server]
   Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:258
   Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:939
   Csla.BusinessListBase`2.Child_Update(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\BusinessListBase.cs:966
   dm(Object , Object[] ) +77
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:357

[CallMethodException: Child_Update method call failed]
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:361
   Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:270
   Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:86
   Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:228

[DataPortalException: ChildDataPortal.Update failed on the server]
   Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:258
   Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:939
   Csla.Core.FieldManager.FieldDataManager.UpdateChildren(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Core\FieldManager\FieldDataManager.cs:544
   GenForm.Library.Apotheek.DataPortal_Update() in D:\Data\VisualStudio\GenForm\GenForm.Library\Entities\Apotheek.DataAccess.cs:132
   dm(Object , Object[] ) +60
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:357

[CallMethodException: DataPortal_Update method call failed]
   Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:361
   Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:270
   Csla.Reflection.LateBoundObject.CallMethod(String method) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:70
   Csla.Server.SimpleDataPortal.Update(Object obj, DataPortalContext context) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\SimpleDataPortal.cs:211

[DataPortalException: DataPortal.Update failed (Csla.DataPortalException: ChildDataPortal.Update failed on the server ---> Csla.Reflection.CallMethodException: Child_Update method call failed ---> Csla.DataPortalException: ChildDataPortal.Update failed on the server ---> Csla.Reflection.CallMethodException: Child_Insert method call failed ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   --- End of inner exception stack trace ---
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 201
   --- End of inner exception stack trace ---
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 201
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 258
   at Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:line 939
   at Csla.BusinessListBase`2.Child_Update(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\BusinessListBase.cs:line 966
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   --- End of inner exception stack trace ---
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 201
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 258
   at Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:line 939
   at Csla.BusinessListBase`2.Child_Update(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\BusinessListBase.cs:line 966
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 228
   --- End of inner exception stack trace ---
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 201
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 258
   at Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:line 939
   at Csla.BusinessListBase`2.Child_Update(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\BusinessListBase.cs:line 966
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 361
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 270
   at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\LateBoundObject.cs:line 86
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 228
   at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Server\ChildDataPortal.cs:line 258
   at Csla.DataPortal.UpdateChild(Object child, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\DataPortal.cs:line 939
   at Csla.Core.FieldManager.FieldDataManager.UpdateChildren(Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Core\FieldManager\FieldDataManager.cs:line 544
   at GenForm.Library.Apotheek.DataPortal_Update() in D:\Data\VisualStudio\GenForm\GenForm.Library\Entities\Apotheek.DataAccess.cs:line 132
   at dm(Object , Object[] )
   at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Visual Studio Projects\csla\Source\cslacs\Csla\Reflection\MethodCaller.cs:line 357)]
   GenForm.MVC2.Controllers.FormulariumController.Create(FormCollection formValues) in D:\Data\VisualStudio\GenForm\GenForm.MVC2\Controllers\FormulariumController.cs:63
   lambda_method(ExecutionScope , ControllerBase , Object[] ) +140
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
   System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +52
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
   System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314
   System.Web.Mvc.Controller.ExecuteCore() +105
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

 

tbim92 replied on Friday, April 15, 2011

Has this been resolved? I am getting the same error and a similar, very long stack trace with multiple levels of nested errors (inner exceptions). I am on VS2010 SP1 and CSLA 4.1.0. The stack trace is very long, but I can email it immediately if needed. The last of the nested errors is:

            InnerException: Csla.Reflection.CallMethodException

                 Message=Child_Insert method call failed

                 Source=Csla

                 StackTrace:

                      at lambda_method(Closure , Object , Object[] )

                      at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Reflection\MethodCaller.cs:line 545

                      at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Reflection\MethodCaller.cs:line 549

                      at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Reflection\MethodCaller.cs:line 413

                      at Csla.Reflection.LateBoundObject.CallMethod(String method, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Reflection\LateBoundObject.cs:line 93

                      at Csla.Server.ChildDataPortal.Update(Object obj, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Server\ChildDataPortal.cs:line 214

                 InnerException: System.IndexOutOfRangeException

                      Message=Index was outside the bounds of the array.

                      Source=Anonymously Hosted DynamicMethods Assembly

                      StackTrace:

                           at lambda_method(Closure , Object , Object[] )

                           at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) in C:\Dev.VS\Frameworks\CSLA\CSLA\Reflection\MethodCaller.cs:line 545

Thank you.

RockfordLhotka replied on Friday, April 15, 2011

The CSLA CallMethod method implements a late bound method calling convention that supports overloaded methods. There is at least one known issue with passing a parameter that is an array that I have been unable to resolve - literally because at runtime it is impossible to differentiate that value from other value types - the information just doesn't exist.

I don't know what you are passing into the data portal's UpdateChild method as a parameter, but it is possible you are hitting this unresolvable edge condition.

Which is a long winded way of asking you: what are you passing as a parameter to UpdateChild?

tbim92 replied on Friday, April 15, 2011

Sorry for the delay in the reply. I wanted to test something with it before submitting the update - nothing to note on the test though.

 

I my case i have an Editable Root List (LocationList) with Editable child objects (Location). I added a child object and ran the "LocationList = LocationList.Save();" command.

My LocationList code is:

    [Csla.Transactional(Csla.TransactionalTypes.TransactionScope)]

    protected override void DataPortal_Update() { base.Child_Update(); }

My Location code, which execution never reaches, is:

   private void Child_Update(object parent) { DoUpdate(); }

The line of code that has the error is in "MethodCaller.CallMethod(object obj, System.Reflection.MethodInfo info, params object[] parameters)" on the last try/catch at "result = methodHandle.DynamicMethod(obj, inParams);". The obj object is my Location business object and looks like a typical object; it is valid, dirty, new and a child (I checked all these values). The inParams is an emtpy object array - its length is 0. The error occurs executing this line. I can't step into this method call. I put a breakpoint in the DynamicMethodHandle method but it never gets there before the error.

Is there anything else I can provide? I'll email the entire call stack, send you screenshots, let you screen share and walk through the code yourself - anything! I'm completely stumped.

I have another object tree that is Parent - child list - child objects - child list - child object. Saving a new item works fine in that object tree (with a single grandchild and great-grandchild added). The two child objects there appear to be exact duplicates to the one that is getting the error - with the exception of the properties of course.

Thank you.

RockfordLhotka replied on Friday, April 15, 2011

The core issue here is that your Child_Update call is provided with 0 parameters, and your Child_Update expects 1 parameters.

base.Child_Update just finds all child references and calls DataPortal.UpdateChild on each one, passing the (non-existant) parameters you provide.

The MethodCaller implementation in CSLA is then looking for a Child_Update, Child_Insert, or Child_DeleteSelf method that accepts 0 parameters.

The exception could probably be better here, but ultimately the issue is that you don't have such a method (with 0 parameters), so it fails.

tbim92 replied on Friday, April 15, 2011

Thank you! I'm not sure I would have thought of that. I wonder why my other two objects worked. They were the same way.

In case anyone else reads this post, to solve the problem, in my List object's DataPortal_Update() method I had one line of code: "base.Child_Update();". I changed it to "base.Child_Update(this);" which matches my child object's "Child_Insert(object parent)" and "Child_Update(object parent)" methods and that solved the problem.

I appreciate your time.

sergioadh replied on Saturday, May 14, 2011

I could use exactly what you do inside those methods, I'm experiencing a problem of the like now.

 

Thanks

JCardina replied on Thursday, November 10, 2011

Hi Rocky, I just ran into this as well with csla 4.1 and I wasted a *lot* of time on it, thank you for posting the suggestion, it pointed directly to the problem which was my own.

I agree with you wholeheartedly that the exception message could be better there.  I urge you to consider making a change to that message to avoid anyone else wasting a lot of time chasing wild geese in future.

Copyright (c) Marimer LLC