I am getting an exception while using Demo007 from the Silverlight Samples. I receive the exception when I click on the Delete button in the DataGrid on the "Edit Categories" page. The exception I get is the following:
System.NotSupportedException was unhandled by user code
Message="Method to be executed must have 0 or 2 parameters"
at Csla.Silverlight.InvokeMethod.CallMethod(Object sender, EventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
When I debug this, it looks like the CallMethod function is trying to call the RemoveItem on the CslaDataProvider. The RemoveItem function has 1 parameter, which causes the Exception to occur.
Some of the other pages (like Add Order) in this demo do work. The difference, however is that they don't use the InvokeMethod way of deleting the items. They do the delete in the code-behind instead.
I have tried using CSLA 3.8.1, 3.8.2, and 3.8.3 (beta 3) with the same results.
Does anybody else have this same issue?
Those demos were originally created using 3.6 and were later updated for SL3 and 3.7. They have not been updated for 3.8.
InvokeMethod has changed over time, and 3.8 is different from 3.7 - to bring it in line with the new Execute trigger action - so it requires 0 or 2 parameters on the target method. The 2 parameter model is:
public void TargetMethod(object sender, ExecuteEventArgs e)
You should know that the Execute trigger action is gone in CSLA 4 - because it turns out that the Blend SDK includes the same functionality already. And in 3.8.3 and higher I'll be recommending people move away from InvokeMethod to the new TriggerAction (which is in CSLA 4, and I just back-ported to 3.8.3) control because it is more powerful and works with the VS10 designer tools.
Copyright (c) Marimer LLC