DesignTime_Create: is this valid?

DesignTime_Create: is this valid?

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


ajj3085 posted on Monday, December 01, 2008

Hi,

I have implemented DesignTime_Create for Wpf designer support.  In part of it, I call LoadProperty to populate a child object which is a BLB.  The BLB has a DataPortal_Fetch which takes no parameters and fills the list with dummy data, and the factory method called in the root's DesignTime_Create uses the FetchChild of the dataportal.

Should the child dataportal continue to function normally?  I'm asking because I never see any data in the grid which is bound to the child BLB.

Thanks
Andy

ajj3085 replied on Monday, December 01, 2008

Also, attaching another instance of VS 2008 to the one which has the Wpf controls doesn't seem to hit the breakpoint set in DesignTime_Create.  The business module is loaded.. any ideas there?

RockfordLhotka replied on Monday, December 01, 2008

DesignTime_Create() is a special case, where the data portal simply invokes the method and does no further work. So no, the data portal is generally not available within DesignTime_Create().

Why you don't hit the breakpoint in the second VS instance is a mystery. It isn't entirely clear how VS is executing the code, and it may be spawning a background process or appdomain to run that code (so it doesn't lock a DLL in a bad way), and that could interfere with attaching a debugger.

ajj3085 replied on Monday, December 01, 2008

Well, I at least found why the designer doesn't hit the code I expect.  My CanCreate static method is executing (because the designer execute the New factory method), but because there's no configuration file in the format my configuration reading assembly expects, it throws an exception.

I've thought about added code to bypass security checks if Csla.DataPortal.IsInDesignMode is true, but that feels like a security risk.  Maybe some #if directives can help me, although they feel "dirty."

Copyright (c) Marimer LLC