Howdy There!
I'm a CSLA newbie/hobbyist programmer and I'm having a slight difficulty! (Go figure! )
I'm having a problem with getting the windows phone version of SimpleApp to run properly. When I debug the solution, it compiles and deploys to the Windows Phone emulator fine. I type any string in the name textbox ("butters" e.g.) and then choose save. This then throws a NotSupportedException (message: "Invalid operation - insert not allowed") at CustomerEdit.BeginSave(forceUpdate,handler,userState). The full exception message is appended to this post.
Here is some possibly useful information:
The specific sample is located in the "CslaSamples-4.1.0-110118" download, "\Samples\WindowsPhone\cs\SimpleApp".
I'm learning CSLA on a budget - I've read the overview cover-to-cover. Hopefully will get the Business Objects soon(!!)
Thanks in advance for any help anyone can provide!! I apologize if it's an obvious answer! I've looked extensively through this forum and on google and I just can't find anyone else that has this problem, so I figure it must be my newbness.
-Bill
Full Exception: ------------------
System.NotSupportedException was unhandled
Message=Invalid operation - insert not allowed
StackTrace:
at Csla.BusinessBase`1.DataPortal_Insert(CompletedHandler handler)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Csla.Reflection.MethodCaller.CallMethod(Object obj, MethodInfo info, Object[] parameters)
at Csla.Reflection.MethodCaller.CallMethod(Object obj, String method, Object[] parameters)
at Csla.DataPortalClient.LocalProxy`1.BeginUpdate(Object obj, Object userState)
at Csla.DataPortal`1.BeginUpdate(Object obj, Object userState)
at Csla.DataPortal.BeginUpdate[T](Object obj, EventHandler`1 callback, Object userState)
at Csla.DataPortal.BeginUpdate[T](Object obj, EventHandler`1 callback)
at Csla.BusinessBase`1.BeginSave(Boolean forceUpdate, EventHandler`1 handler, Object userState)
at Library.CustomerEdit.BeginSave(Boolean forceUpdate, EventHandler`1 handler, Object userState)
at Csla.BusinessBase`1.BeginSave()
at Csla.BusinessBase`1.Csla.Core.ISavable.BeginSave()
at Csla.Xaml.ViewModelBase`1.BeginSave()
at Csla.Xaml.ViewModel`1.Save(Object sender, ExecuteEventArgs e)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Csla.Xaml.TriggerAction.CallMethod(Object sender, EventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
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)
Well, I added the following code to the area beneath the !SILVERLIGHT directive in CustomerEdit.cs:
#region Data Access
#if !SILVERLIGHT...
#endif
public override void DataPortal_Insert(LocalProxy<CustomerEdit>.CompletedHandler handler)
{
try
{
System.Threading.Thread.Sleep(1500);
using (BypassPropertyChecks)
{
Id = 987;
Status = "Inserted " + ApplicationContext.ExecutionLocation.ToString();
}
handler(this, null);
}
catch (Exception ex)
{
handler(null, ex);
}
}#endregion //DataAccess
That seemed to do the trick. I was thinking there was some other problem with my environment that I just wasn't seeing but I think maybe the sample just isn't complete? Any thoughts would be welcome!
I think this is a bug in the sample, yes. I'm glad you found the answer.
I'm glad too!!!! I'm loving CSLA so far! Thanks for the superior product sir.
-Bill
Copyright (c) Marimer LLC