StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Exception when setting RequiredFieldsExpand / Collapse
Author
Message
Posted 06/13/2006 2:07:18 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
I'm getting the following error for one of my BO's when I try to set the RequiredFields property:

"An error occurred while attempting to load this type editor:
Exception has been thrown by the target of an invocation."

I can map it without error through the BO Mapper and I have created several other BO's without problems.  What could cause something like this?

Post #1523
Posted 06/13/2006 2:25:47 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 4:58:13 AM
Posts: 4,379, Visits: 4,421
Andria,

Rebuild your solution (not just build) and if you still get the error, get out of Visual Studio and come back in and see if the error persists.  Most times this is due to VS trying to hold on to an assembly.

Post #1524
Posted 06/13/2006 2:34:48 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
I rebuilt and still had the same error, then closed all of VS and came back.  Still the same error.  Anything else that could cause this?
Post #1527
Posted 06/13/2006 5:02:10 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
Any suggestions on getting past this problem???  I'm kind of stuck working and can't go forward.
Post #1528
Posted 06/14/2006 9:27:08 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
Are there any compiler errors within the project, or does it build properly?

Are you getting the same error within other business objects, or just that one business object.

If it is localized to a single business object, can you post the main code file and the designer file for the business object here on the forum (or email it to me) so I can step through it and see if we can track down the problem?


www.bungie.net
Post #1532
Posted 06/14/2006 10:03:31 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
It compiles fine and I even used it as a reference in another project.  I just can't get to the required fields.  I'm having the issue only with one other BO at this time.  I'm attaching the projects I'm having problems with and maybe you can tell me if I've done something wrong.  I followed the same steps I've taken to create a lot of other BOs, but these don't seem to work like the rest.

  Post Attachments 
ReqFieldsException.zip (15 views, 110.40 KB)
Post #1537
Posted 06/14/2006 10:42:36 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
The reason it's throwing an exception is that you're filling the business object within the constructor.  When you are in the designer, all code within the constructor is executed at design-time because the designer creates instances of the objects at design-time.  When your objects are created, they're trying to fill themselves, and since the DataSource("") is the data source being used by StrataFrame, it cannot find your tables, and therefore cannot fill the business object at design-time.  Your best solution is to remove the FillDataTable method from the constructor and do one of two things: 1) Create a Shared "factory" method that will create new instances of the business objects and fill them before returning their references, or 2) Just manually call the FillDataTable method after the object is created.


www.bungie.net
Post #1540
Posted 06/14/2006 10:56:23 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 08/21/2008 11:49:01 AM
Posts: 303, Visits: 435
OK, that makes sense.  I can figure something else out to accomplish this.  A factory method will probably be a good way for me to go.  Thanks for the help!
Post #1542
Posted 06/14/2006 1:31:01 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
Andria,

I forgot to mention that if you ever want to test on some code that should on run at design-time, you can use the ReadOnly DesignMode property, like this:

If Me.DesignMode Then

'-- Code that should only run at design-time

End If

Unfortunately, this won't help you in this case, because the DesignMode property will always return False (because it isn't set) until after the constructor exits.  So, once an object has been instantiated, you can test on the property, but until it has been set, you cannot use it. 

Oh, and the property is Protected, so you can only access it within the object (unless you wrap it in a public property).


www.bungie.net
Post #1544
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
A