Exception when setting RequiredFields


Author
Message
Andria Jensen
Andria Jensen
StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)
Group: Forum Members
Posts: 336, Visits: 497
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?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.

Andria Jensen
Andria Jensen
StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)
Group: Forum Members
Posts: 336, Visits: 497
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?
Andria Jensen
Andria Jensen
StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Any suggestions on getting past this problem???  I'm kind of stuck working and can't go forward.
StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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?

Andria Jensen
Andria Jensen
StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)
Group: Forum Members
Posts: 336, Visits: 497
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.
Attachments
ReqFieldsException.zip (149 views, 110.00 KB)
StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
Andria Jensen
Andria Jensen
StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)StrataFrame User (416 reputation)
Group: Forum Members
Posts: 336, Visits: 497
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!
StrataFrame Team
S
StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)StrataFrame Developer (4.3K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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).

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search