Possible bug in CSLA 3.8.2

Possible bug in CSLA 3.8.2

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


rhertzberg posted on Monday, February 08, 2010

I'm experiencing a crash condition when processing one of my business lists that I think may be related to some code in BusinessListBase.cs  To make a long story short, I was able to fix the problem when I switched the order of the last 2 lines of BusinessListBase.InsertItem() to look like this:

    protected override void InsertItem(int index, C item)
    {
      // set parent reference
      item.SetParent(this);
      // set child edit level
      Core.UndoableBase.ResetChildEditLevel(item, this.EditLevel, false);
      // when an object is inserted we assume it is
      // a new object and so the edit level when it was
      // added must be set
      item.EditLevelAdded = _editLevel;
      InsertIndexItem(item);
      InsertIntoMap(item, index);
      base.InsertItem(index, item);
    }

If base.InsertItem() is performed before InsertIntoMap(), I crash when processing the ListChanged event that fires after base.InsertItem() is called.  In my event handling code I call the Linq ToList() operator and it looks like it needs InsertIntoMap() processing for it to work correctly.

 If this doesn't make any sense, let me know and I'll write a test app to demonstrate it.  Thanks. 

RockfordLhotka replied on Friday, February 12, 2010

I've referred this to Aaron, who maintains the LINQ to CSLA behaviors - including indexing.

Can you provide the test app to demonstrate the issue? Clearly there's something relatively unique in your code, since this hasn't been reported by others, and so we need to understand the specifics of how your code is interacting with indexing.

fwiw, indexing has been removed in CSLA 4 because it has been a PITA having it embedded in CSLA. If you need indexing you'll be able to get it by using external libraries such as i4o.

rhertzberg replied on Saturday, February 13, 2010

Rocky,

Attached is a test app that demonstrates the failure.  It creates a Customer record that contains a list of Order records.  The orders are displayed in a ListView.  When you click the Add Order button, a new order is created and added to the order list.  The OnListChanged member receives the ListChanged event fired by the order list.  It does a couple of Linq operations and crashes on the last.

The source for CSLA version 3.8.2 is included as a subsidiary project of the solution so I could see where the failure is occuring in the source code.  Let me know if you have any trouble building it or reproducing the problem.

Richard

Copyright (c) Marimer LLC