Stack overflow

Stack overflow

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


ajj3085 posted on Thursday, September 21, 2006

Ok, I've overriden methods to prevent adding or removing (or setting via indexer) objects in a BuisnessListBase.

Of course, when loading the list, I got an exception.  Not suprising.  So I added a private IsLoading flag, much like IsReadOnly on ReadOnlyListBase.

I'm hitting a weird problem now..

Here's the load method

        private void LoadSelf( PriceList priceList ) {
            List<Data.Quoting.ProductPrice> results;
            Data.DataSearcher<Data.Quoting.ProductPrice> searcher;
            Data.SelectionCriteria crit;

            crit = new Data.SelectionCriteria(
                "PriceListId", Data.Operator.Equals );
            crit.Values.Add( priceList.PriceListId );

            searcher = new Data.DataSearcher<Data.Quoting.ProductPrice>();
            searcher.AddSelectionCriteria( crit );

            results = searcher.Find();

            IsLoading = true;
            foreach ( Data.Quoting.ProductPrice price in results ) {
                Add( ProductPrice.GetProductPrice( price ) );
            }
            IsLoading = false;
        }

And here's the InsertItem override (which is apparently fired by the call to Add):

        protected override void InsertItem( int index, ProductPrice item ) {
            if ( IsLoading ) {
                base.Insert( index, item );
            }
            else {
                throw new NotSupportedException( "Price cannot be inserted." );
            }
        }

This bombs with a StackOverflowException.  For some reason, base.Insert is causing a problem.  I press F11 to 'step into' the code, which should lead me to the Csla BusinessListBase.InsertItem method, but for some reason that doesn't happen, and the cursor appears right back on base.Insert.  It seems like instead of calling base, its calling this.

Any ideas?
Thanks
Andy

ajj3085 replied on Thursday, September 21, 2006

Opps, nevermind!

I had Insert instead of InsertItem... doh!

Copyright (c) Marimer LLC