The variable 'configurationAppSettings' is either undeclared or was never assigned.

H

hui

Here is a problem I am having with web form designer. I have a database
control in the form, and setup the connection string as a dynamic
property. It compiles and runs fine.

I close the aspx file, reopen it, and then have an error message in
task list: "\\xxx\wwwroot$\xxx\xx.aspx.cs(68): The variable
'configurationAppSettings' is either undeclared or was never assigned"

I open the code-behind file, and find out the trouble spot at the "web
designer generated code" region. The method looks like this:
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings =
new System.Configuration.AppSettingsReader();
.......
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString =
((string)(configurationAppSettings.GetValue("dbConnection",
typeof(string))));
.......
}

Obviously the variable is declared and assigned locally. Go back to the
design editor, in the property window of the db connection control, the
dynamic property setting has disappeared. Yet, if I rebuild now, it
compiles and run just like before. If I any changes on the design
editor, the code-behind file is changed and the statement "
this.sqlConnection1.ConnectionString = ...." is wiped out. This is
definitely not what I want to see as I have to set it up again and
again.

Does anybody know whether it is a bug? Is there any fix or workaround?

Thanks
 
M

Mohamed Sharaf

Hi hui,
What's the version of Visual Studio you are using?
What's the type of the connection you are using, is it SqlConnection,
OledbConnection,....?


BTW: Avoid using your real email. You can use something like
(e-mail address removed) or if you want it to be human readable. use
something like mild_roast_at_hotMail

Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
--------------------
| From: "hui" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: The variable 'configurationAppSettings' is either undeclared or
was never assigned.
| Date: 12 Oct 2005 22:03:27 -0700
| Organization: http://groups.google.com
| Lines: 37
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 210.193.130.211
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129179812 6582 127.0.0.1 (13 Oct 2005
05:03:32 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Thu, 13 Oct 2005 05:03:32 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
..NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
| X-HTTP-Via: 1.0 SYDPRX01
| Complaints-To: (e-mail address removed)
| Injection-Info: g49g2000cwa.googlegroups.com;
posting-host=210.193.130.211;
| posting-account=i6V1NAwAAACRY9W_sJxyoOElwFrBeWVz
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!g4
9g2000cwa.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:131010
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Here is a problem I am having with web form designer. I have a database
| control in the form, and setup the connection string as a dynamic
| property. It compiles and runs fine.
|
| I close the aspx file, reopen it, and then have an error message in
| task list: "\\xxx\wwwroot$\xxx\xx.aspx.cs(68): The variable
| 'configurationAppSettings' is either undeclared or was never assigned"
|
| I open the code-behind file, and find out the trouble spot at the "web
| designer generated code" region. The method looks like this:
| private void InitializeComponent()
| {
| System.Configuration.AppSettingsReader configurationAppSettings =
| new System.Configuration.AppSettingsReader();
| ......
| //
| // sqlConnection1
| //
| this.sqlConnection1.ConnectionString =
| ((string)(configurationAppSettings.GetValue("dbConnection",
| typeof(string))));
| ......
| }
|
| Obviously the variable is declared and assigned locally. Go back to the
| design editor, in the property window of the db connection control, the
| dynamic property setting has disappeared. Yet, if I rebuild now, it
| compiles and run just like before. If I any changes on the design
| editor, the code-behind file is changed and the statement "
| this.sqlConnection1.ConnectionString = ...." is wiped out. This is
| definitely not what I want to see as I have to set it up again and
| again.
|
| Does anybody know whether it is a bug? Is there any fix or workaround?
|
| Thanks
|
|
 
H

hui

FYI, the version I am using is vs.net 2003, version 7.1.3088. I am
using sqlconnection.

BTW, I think I've found the cause, but am not clear why. Under the
References folder in the Solution Explorer window, I set the "Copy
Local" property of System assembly to "true". As a result, the designer
couldn't function properly on the dynamic properties. Immediately after
I change it back to "false", such errors in the task list are all gone.
Change back to true, so comes back the same errors. It doesn't make
much sense to me, however.

Thanks,

Hui
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top