Can't access PropertyInfo in OnDeserialized() override in CSLA 3.5 (Index still -1)

Can't access PropertyInfo in OnDeserialized() override in CSLA 3.5 (Index still -1)

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


rsbaker0 posted on Thursday, October 29, 2009

So, I thought I stumbled into the problem with derived classes and properties not being registered and have researched the various threads, but now I'm not sure it's the same problem.

I'm trying to access a managed property in OnDeserialized(), but the field index is still -1.

If I look into the BusinessBase OnDeserialized() handler, I see that FieldManager.SetPropertyList() is called *after* OnDeserialized is called, so I'm kind of stuck here.

Any thoughts on how to work around this?

RockfordLhotka replied on Thursday, October 29, 2009

Somewhere between 3.5 and 3.8 this bug was caught and fixed.

So you can either fix the bug in your copy of CSLA or upgrade.

rsbaker0 replied on Thursday, October 29, 2009

Do you recall if the fix was in OnDeserializedHandler() or was implemented elsewhere?

A clumsy work around I implemented was to check the property index in advance and it if is -1, to just create a dummy object of the same class. Ugly, but it seems to work...

RockfordLhotka replied on Thursday, October 29, 2009

It was fixed in OnDeserializedHandler(). If you look at the current code, it
is ordered correctly.

Copyright (c) Marimer LLC