StrataFrame Forum

Error with usercontrol

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

By Rav - 4/20/2007

I have a usercontrol with a  BO and some textboxes bound to a businessBindingsource.  When I drag the usercontrol onto a blank strataframe standard form, i get an error "Failed to create component... cannot bind to property or column... Please see screenshot for the full error msg.  If I set the binding property of the textboxes to none, I can drag the control onto the form with no problem.
By StrataFrame Team - 4/20/2007

This looks like an instantiation order problem.  Most likely, the BBS's BusinessObject property is not being set within the InitializeComponent of the UserControl before the Binding is added to the textbox's DataBindings collection.  There's not a way to force the textbox to wait until the BO has been set to add the binding.  You can, however, create an inherited BusinessBindingSource and in it's constructor add an instance of the business object that you need.  The business object would be contained within the BBS, so that might cause some problems if you want to handle BO events on the user control (you would just have to add the handlers manually...).   Another option would be to copy the designer code for the creation of the bindings and move the code out off the .designer.* file and into the constructor of your user control after InitializeComponent() is called.  This would force the textboxes to wait until the BusinessObject has been set before binding to the BBS.
By Rav - 4/23/2007

Ben Chase (04/20/2007)
This looks like an instantiation order problem.  Most likely, the BBS's BusinessObject property is not being set within the InitializeComponent of the UserControl before the Binding is added to the textbox's DataBindings collection.  There's not a way to force the textbox to wait until the BO has been set to add the binding.  You can, however, create an inherited BusinessBindingSource and in it's constructor add an instance of the business object that you need.  The business object would be contained within the BBS, so that might cause some problems if you want to handle BO events on the user control (you would just have to add the handlers manually...).   Another option would be to copy the designer code for the creation of the bindings and move the code out off the .designer.* file and into the constructor of your user control after InitializeComponent() is called.  This would force the textboxes to wait until the BusinessObject has been set before binding to the BBS.

That fixed it.  Thank you.  However, when I try to run my app I now get a "User Authentication" screen asking for a username and password.  I'm haven't experimented with any role based security yet and I'm using windows authentication for sql server.  What password is this asking for?

By Ivan George Borges - 4/23/2007

Hi Rav.

Have a look at the Help File, under "Defining Security within the Application".

I guess you created your application using the "Strataframe Windows Application w/ Security" template. So, if you have a look at your AppMain.vb (or Program.cs) you will find the code that does the trick, according to the help file.

There are some built in accounts and passwords set in there (InitApplication). You can change them or use as they are.

Hope it helps.

By StrataFrame Team - 4/24/2007

Yes, if you created your app with the "w/ Security" template, then there will be some code in the ShowLoginAndInitMainForm method of the AppMain.vb (Program.cs) file.  Just comment that code out and it will remove the login form.  There is also some other code that is in there that you'll probably want to comment out as well.  The help topic Ivan mentioned describes each extra piece and what it does.
By Rav - 4/24/2007

Thank you Ivan and Ben