Maximum number of properties allowed in WinRT object? (Adding the 59th property breaks DP method)

Maximum number of properties allowed in WinRT object? (Adding the 59th property breaks DP method)

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


TSF posted on Saturday, November 15, 2014

Scenario: WinRT project with CSLA 4.5.

I've come across a weird situation where when I add one additional property to a particularly large object, the object breaks when the DP_Create method is called. It doesn't matter what kind of property I add (bool, int, whatever). The object has 58 properties, but when the 59th is added, I get an exception.

In a factory method on the object, I'm calling the DP_Create method as as follows:

var line = DataPortal.Create<OrderLineEdit>(criteria);

When this line is executed, I get back the following error without any chance of stepping into the DP_Create method even though a breakpoint is in there.

"An exception of type 'Csla.DataPortalException' occurred in mscorlib.dll but was not handled in user code

Additional information: DataPortal.Create failed (Object reference not set to an instance of an object.)"

I've spent hours going through the possibilities, including making sure all objects, including criteria objects, have default public constructors which I've found are needed in WinRT. The DP_Create method is run locally, per our custom proxy factory and by the fact it is in a compiler directive to run only NETFX_CORE, and I've even marked the method with the [RunLocal] attribute just to make sure, with that making no difference. Everything being done in this local DP_Create method does nothing spectacular (no database calls obviously, not interaction with other objects...simply setting simple type properties like ints, strings, etc.).

What I've finally stumbled onto is that when I remove a property (any property), everything starts working. And when I add a new property (of any data type, with any random name and not referenced by any code) it stops working and throws this exception. This leads me to the question of whether there is any sort of max # of properties allowed on an object running in the WinRT stack.

Any ideas? Thanks.

RockfordLhotka replied on Monday, December 15, 2014

That's very strange. Still having this issue? If so can you post the stack trace, not just the top level exception?

Copyright (c) Marimer LLC