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

Discussion in 'ASP .Net' started by hui, Oct 13, 2005.

  1. hui

    hui Guest

    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
     
    hui, Oct 13, 2005
    #1
    1. Advertising

  2. 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
    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" <>
    | 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: <>
    | 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:
    | 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:
    | 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
    |
    |
     
    Mohamed Sharaf, Oct 13, 2005
    #2
    1. Advertising

  3. hui

    hui Guest

    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
     
    hui, Oct 14, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad Smallridge

    undeclared loop variable

    Brad Smallridge, Mar 23, 2005, in forum: VHDL
    Replies:
    7
    Views:
    708
    Michael
    Mar 25, 2005
  2. Soren Kuula
    Replies:
    1
    Views:
    473
    Henry S. Thompson
    Dec 1, 2005
  3. Kevin
    Replies:
    4
    Views:
    447
    Irrwahn Grausewitz
    Oct 17, 2003
  4. JulioNobre
    Replies:
    0
    Views:
    6,996
    JulioNobre
    Sep 26, 2006
  5. elin05
    Replies:
    7
    Views:
    1,473
    joris
    Jul 21, 2010
Loading...

Share This Page