StrataFrame Forum

BOTranslations using SF UserControl

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

By Jeff Pagley - 8/21/2008

Hi SF Team,

I have created an SF User control which contains CampaignSalesBO (Child BO).  I have placed the user control on a SF Form which contains CampaignContactsBO (Parent BO).  Then I configured the BOTranslations for the user control using the wizard. When I attempt to load the form I get the following error.  I don't know what I am doing wrong. 

As always thank you for the help!

Jeff

Object of type 'AutoDialer.CampaignContactsBO' cannot be converted to type 'AutoDialer.CampaignsSalesBO'.
  Exception (ArgumentException): Source="mscorlib"; Target=null; Tag=null; ParamName=null;
    Message = "Object of type 'AutoDialer.CampaignContactsBO' cannot be converted to type 'AutoDialer.CampaignsSalesBO'."
  Environment: ThreadIdentity="" DateTime=["2008-08-21 23:11:13.343"] ThreadName=null WindowsIdentity="STRUSS\JPagley" ThreadId="10" DomainName="AutoDialer.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 Service Pack 3"] MachineName="1LPJPAGLEY"
    UserName="JPagley"
  Remaining Stack Trace  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
    at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
    at System.Reflection.RtFieldInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
    at MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslator.SetBusinessObjectReference(ContainerControl ParentControl, BusinessLayer SourceBusinessObject, String DestinationBusinessObjectName)
    at MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslator.TranslateBusinessObjects(BusinessObjectTranslationCollection Translations, ContainerControl SourceContainer, ContainerControl DestinationContainer)
    at MicroFour.StrataFrame.UI.Windows.Forms.UserControl.TranslateBusinessObjects()
    at MicroFour.StrataFrame.UI.Windows.Forms.UserControl.InitializeObject()
    at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()
    at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
    at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By Paul Chase - 8/22/2008

Hi Jeff,

The BO translations are intended to wire up to BO's of the same type. ie MYBO on my main for translates to MYBO on my usercontrol, it looks like you are attempting to wire up MYBO to MYCHILDBO. So you probably need to either put and instance of the child bo on your main form or the parent bo on your usercontrol and map them accordingly to whatever makes sence in your app.

By Dustin Taylor - 8/22/2008

That's not exactly how the BOTranslations work. The BOTranslations lets the "child" business object within a user control interact with the "parent" business object on the parent form, but both of these business objects are just instances of the same BO. Apples to apples if you will Smile

You are setting up a Child-Parent relationship between two different BOs, Apples to Oranges. If the only thing your user control deals with are the CampaignSales, then you'll want to place another CampaignSalesBO on your parent form, and set up the parent relationship between it and the CampaignContacts on your main form. That will handle your parent-child relationship, and will give your user control something to talk to on your form.

By Dustin Taylor - 8/22/2008

Snap, I got distracted and Paul beat me to it.

What he said BigGrin