Need help with breaking change when moving from 2.x to 3.8.1

Need help with breaking change when moving from 2.x to 3.8.1

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


JonM posted on Thursday, December 24, 2009

When I call the ApplyEdit() I get a "Edit level mismatch in AcceptChanges" error. I've search the forum but the answers are confusing. Has the model changed? Should I still be calling AppyEdit() before saving?

Example Code:

if (m_Machines.IsDirty)
{
if (m_Machines.IsValid)
{
m_Machines.ApplyEdit();
m_Machines.Save();
btnSave.Enabled = false;
}
else
{
MessageBox.Show(m_Machines.BrokenRules, "Cannot save changes", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

RockfordLhotka replied on Thursday, December 24, 2009

There were some substantial changes to the way n-level undo interacts with Windows Forms data binding in 3.0. The Using CSLA .NET 3.0 ebook has a chapter on that topic.

Additionally, 3.0 added exceptions to help you identify mis-matched BeginEdit calls that don't have corresponding ApplyEdit/CancelEdit calls. These exceptions are designed to help identify bugs in UI code - usually bugs that were unnoticed, but often caused very hard to track down issues.

ajj3085 replied on Tuesday, December 29, 2009

Just want to add that its critical you fix this, and not just try to work around it.  It means your data binding won't work correctly in some cases.

If possible, just use the BindingSourceNode.. it will make everything so much easier.

Copyright (c) Marimer LLC