StrataFrame Forum

BO translation and subclassing

http://forum.strataframe.net/Topic27215.aspx

By dgsoft - 5/24/2010

Hi, I have an environment

Step1.

[UserControl1 (based on SF userControl)

_|___ UserControl2 (based on SF userControl)

_|_________|____ BO2

_|___BO1



Between BO1 and BO2 I have translation.



Step2.

[Form]

__|___ UserControl1

__|________|___ BO1

__|__BO0



Between BO0 and BO1 I have translation.



This combination works perfect.



Step3.

I create UserControl3 based on UserControl1 !!!

When form starts I'v got an error message now. (below)

It seems in subclassing my BO translation lost. I try to make BO as Public but it does not help.

Any idea?





BusinessLayerException

The business object [BO1] could not be located. It is most likely this object was deleted or renamed.



Source : MicroFour StrataFrame UI



Stack Trace:

bei MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslator.GetBusinessObject(ContainerControl ParentControl, String BusinessObjectName)

bei MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslator.TranslateBusinessObjects(BusinessObjectTranslationCollection Translations, ContainerControl SourceContainer, ContainerControl DestinationContainer)

bei MicroFour.StrataFrame.UI.Windows.Forms.UserControl.TranslateBusinessObjects()

bei MicroFour.StrataFrame.UI.Windows.Forms.UserControl.InitializeObject()

bei MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()

bei MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)

bei System.Windows.Forms.Form.OnCreateControl()

bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

bei System.Windows.Forms.Control.CreateControl()

bei System.Windows.Forms.Control.WmShowWindow(Message& m)

bei System.Windows.Forms.Control.WndProc(Message& m)

bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)

bei System.Windows.Forms.ContainerControl.WndProc(Message& m)

bei System.Windows.Forms.Form.WmShowWindow(Message& m)

bei System.Windows.Forms.Form.WndProc(Message& m)

bei System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)

bei System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)

bei System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By Greg McGuffey - 5/24/2010

If I'm following you, you likely need to make the field under the BO to be protected. That will make is available to sub-classes. You can change this in the designer, under the Design category in the property window, the Modifier property. If it's set to private, then this could be your problem. If it's already set to something else, then we'll have to dig deeper.
By dgsoft - 5/24/2010

Hi,

UserControl3 inherits UserControl1.



On userControl1 I made BusinessObject public . I expect it will visible for the new Form for BO translation also (new form where I going to place UserControl3), but..



When I put UserControl3 on the form and try to make BO translation, in the Wizard form - I can see NO business object. Just for example, when I drop in design time some new business object to UserControl3 - its avaliable for translation in new form. But if BusinessObject comes from inherited UserControl1 - its not available.



But as I told before.. error comes from case when



UserControl3 Inherists UserControl1..

and UserControl1 has BusinessObject and translation with UserControl2 (userControl2 located in the userControl1 and has same BO).



As I thinking.. the Public Modifier initialize BusinessObject in UserControl3 more late then its using in parent UserControl1 to initialize Translation. and If I use Private BusinessObject - I can't made new translation with new form where UserContrl3 placed.



I hope I explain it good enough.. Smile
By Greg McGuffey - 5/24/2010

At this point, a small sample app would really help. Then I could open it and not only see what's going on, but also offer suggestions (or cry for help Blink from Trent et all). I'd suggest you make a sample app using BOs from the StrataFrameSample, that way I'll have the data/structures already and it will keep it simple.
By dgsoft - 5/27/2010

Hi,

I reproject logic Smile It seems better to place class instance then subclass it.



Thanks

Denis
By Greg McGuffey - 5/27/2010

Glad you got it going. BigGrin