StrataFrame Forum

Business Object Property

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

By Chan - 7/14/2007

Hi,

I defined a property as below. I get error from designer complaint that it is unable to serialize the code for this property. Any ideas?



public MyLibs.MyBO MyBusinessObject

{

get {return _myBO;}

set {_myBO = value;}

}




Any ideas?



Thank you
By Chan - 7/14/2007

Hi,

Attached is the actual error message.
By StrataFrame Team - 7/16/2007

Getting an "Invalid object name 'Companies'" exception seems to be coming back as an SqlException... its probably trying to access the database at design-time.

So, you can do one of 2 things...

1) Find where you're accessing the database during the get {} of that property and wrap it in an if(!this.DesignMode) {} block like this:

if (!this.DesignMode)
{
    // put your code here....
}

2) If you don't want to be able to set the value in the designer (meaning you don't care about telling your LocationsBO which CompaniesBO to use in the form designer), then add the following attributes to your property:

using System.ComponentModel;

...

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

Thse will prevent the form designer from evaluating the property and setting it in the .designer.cs file for your form.