I have an application which gets data to the forms through a datalayer which uses something like this:
public DataTable get(String query, ArrayList parameters = null)
{
using (iDB2Connection cn = new iDB2Connection(ConfigurationManager.ConnectionStrings["iseries"].ToString()))
{
// get the data and return them
}
}
I have forms which get data and this works fine.
However, I created a UserControl which gets data through this method which works fine when I run my project, however, the form which contains the UserControl throws a designer exception.
"To prevent possible data loss before loading the designer, the following errors must be resolved: "
I found that the error is located at the retrieval of the connection string from the <appSettings>.
It throws a nullpointerexception.
But only in design mode. When I ignore it, everything works fine, however, I would like to know how to resolve this.
Why are my <appSettings> null when accessing them through my UserControl?
UPDATE 1
It seems my UserControl doesn't recognize the <appSettings> at all.
When I put this code in my UserControl Load event I get a nullreference as well.
private void SelectUser_Load(object sender, EventArgs e)
{
txtLocation.Text = ConfigurationManager.AppSettings["location"].ToString();
}