'cannot register property after containing type has been instantiated' message on client side

'cannot register property after containing type has been instantiated' message on client side

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

Charleh posted on Wednesday, June 29, 2011

Hi all,

 I have SL4 app using a BO which has one fetch factory method and two properties. The props are declared on a single object (which derives directly from ReadOnlyBase<>) and are loaded during the DP fetch.

I have a very weird scenario going on when deploying the app - on my dev machine, it works fine - the BO renders a report to disk and sends back a string containing the report path and a success true/false flag. When deploying the app and invoking the fetch I get the 'cannot register property' message - but this seems to happen after the fetch (as the fetch renders the report successfully). This appears to be happening on the client side (as far as I can tell)

I never get the error for the 'success' property, only for the URL property - I've made plenty of BOs and I've seen this happen when the wrong type is specified in registerproperty or a property is registered on a subclass without type info - but this one has me stumped!

Any ideas?

Charleh replied on Wednesday, June 29, 2011

After messing with the object putting debug messages in certain places for a couple of hours, I managed to get it working - it seems that putting a debug message write in the silverlight public constructor has fixed the issue...

I still can't work out why though...! Any ideas why the properties were not initialised on the client side after the DP sent the serialized object back?

ajj3085 replied on Saturday, July 02, 2011

What version of Csla are you using?  Are all of your PropertyInfo's public?

Charleh replied on Wednesday, July 06, 2011

Nope, some are private as most are generated - but I hand wrote a couple and they have private in - I changed these to public and it started working (using CSLA 4.1.0)

Is there a reason the propertyinfos need to be public for the silverlight client?

Marjon1 replied on Monday, July 11, 2011

I believe it has to do with the way reflection works within the Silverlight environment, same as public constructors are required.

Copyright (c) Marimer LLC