When I moved to the 4.0.0 preview 2 assemblies I started getting this exception in my FactoryObject class' Fetch method when I call list.AddNew on a list which inherits ReadOnlyListBase. Can someone clarify what this is about?
For AddNew to work, you need to implement AddNewCore. Normally AddNewCore uses the public parameterless constructor, but in Csla you almost never have that (except in SL, I think).
That said, I'm not sure why you'd be calling AddNew on a ROLB class.. AddNew is for grids to add a new row that the user can edit and commit or cancel... but you wouldn't usually want to do that in a ReadOnly scenario since ROLB doesn't provide Save functionality.
A read only list is readonly until you set IsReadOnly = false.
So assuming this happens when you are adding rows from your datasource then in your factory class you must set IsReadOnly to false before you add rows and reset IsReadOnly before the list is returned.
That's true Jonny, but normally when loading data from the database you wouldn't use AddNew(), you'd just use Add().
I'm not sure AddNew() is a supported scenario for a ROLB collection. In CSLA 4 that class now inherits from ObservableCollection<T>, which doesn't have the AddNew() concept normally - though CSLA does add the concept for backward compatibility and because I find it useful. But I only tested AddNew() in BLB and ERLB where it makes logical sense to use the method.
I of course was setting the IsReadOnly property in the factory. I'd originally used AddNew because it had the nice feature of returning a reference to the new item. I switched to Add instead and it works again I was just curious what caused the change because AddNew had been working for me for quite some time.
Copyright (c) Marimer LLC