ReadOnly Collection _indexSet.ClearIndexes(); Null Reference Exception

ReadOnly Collection _indexSet.ClearIndexes(); Null Reference Exception

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


ShawnCamp posted on Tuesday, March 18, 2008

The line _indexSet.ClearIndexes(); fails in a ReadOnly collection when the Clear() method is called because the _indexSet member has not been initialized. The collection i am trying this in has the IsReadOnly flag set to false. I've pasted the actual method that's failing for reference.

Thanks,

Shawn Camp

/// <summary>
/// Prevents clearing the collection.
/// </summary>

protected override void ClearItems()
{
if (!IsReadOnly)
{
bool oldValue = AllowRemove;
AllowRemove =
true;
base.ClearItems();
_indexSet.ClearIndexes();
AllowRemove = oldValue;
}
else
throw new NotSupportedException(Resources.ClearInvalidException);
}

RockfordLhotka replied on Wednesday, March 19, 2008

Thanks! I'll forward this to Aaron so he can take a look at it.

Copyright (c) Marimer LLC