I have a windows forms user control in my project. It has been working on a form with out any issues but suddenly i can no longer use it on any other form. If i try to drag it from the toolbox to a new form, i get this error message
"Failed to create control 'controlName'. The error message follows: system.ArgumentException: the specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider or not valid."
But when i run the project, it compiles with out any errors.
Also, when i want to open the designer of the form which already contains this Usercontrol and running well, the designer does not load and i see error messages below
"To prevent possible data loss before loading the designer, the following errors must be resolved:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
The variable 'MyControlName1' is either undeclared or was never assigned."
i'M not understanding whats going on but the project still builds and runs but definitely something is seriously wrong.
Wrap your user control load methods with:
private void myUserControl_Load(object sender, EventArgs e)
{
if (!this.DesignMode)
{
//....stuff
}
}
It looks like your control is trying to establish a connection with a database on designtime, and the database cannot be found (probably because the designer tries to look in the Visual Studio bin directory).
Your best bet is not to connect a database to a user control in design time, but dynamically link it during runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With