meli

meli

  • NA
  • 55
  • 0

ConfigurationManager caused user control can not be added in the design window form

Apr 24 2009 2:11 PM

Hi All,

I have a user control that calling another data access class, which content the following statement:

String conn = ConfigurationManager.ConnectionString["MyConnectionString"].ConnectionString;

It compiled and run. However, I was not be able to see my form design, it complaining that the control is undeclare or unassign (this is not the exact error but something like this). If I ignore the error it still run fine, but it just so annoying that you can't see the design view. If you click "Ignore and Continue", you can see the disgn but you will loss the control.

I know for sure the control object is declared and initialized properly. After a long debugging, I found out that the above statement is the soource of the problem.

When I hard-code the connection string directly, without calling ConfigurationManager. It works, I can see my deaign again.

BTW, I am using C#, VS 2008 Prof.

Is this a bug from Microsoft or I did something wrong?

I  want to try to initialize the ConfigurationManager, but I have no idea how to do it.

Thank you all for your help.

 

Cheers,


melania