ConfigurationSettings.AppSettings Error

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default RE: ConfigurationSettings.AppSettings Error

    Hello Chris,

    When you are experiencing this problem? What are you including in the
    AppSettings Config file.
    Are you using long string? What characters are you using in this
    configuration section?
    Can you provide some sample when it will fail?

    I am including below a Kb article that you might find useful:

    311515 HOW TO: Store Data in Application Scope by Using ASP.NET and Visual
    C#
    [url]http://support.microsoft.com/?id=311515[/url]


    Thanks,
    Bassel Tabbara
    Microsoft, ASP.NET

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    | From: "Chris" <chris.bolyard@softvu.com>
    | Subject: ConfigurationSettings.AppSettings Error
    | Date: Wed, 2 Jul 2003 08:43:12 -0500
    | Lines: 10
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    | Message-ID: <OzjeR8JQDHA.3768@tk2msftngp13.phx.gbl>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: host46-162.discord.birch.net 65.16.46.162
    | Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    | Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:31709
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Has anybody experience and/or resolved randomly getting NULL back from
    | ConfigurationSettings.AppSettings?
    | Framework 1.1
    |
    | We may need to setup a stress test to determine how often this occurs, but
    | googling shows there are other cases.
    |
    | Thanks, Chris
    |
    |
    |


    Bassel Tabbara [MSFT] Guest

  2. Similar Questions and Discussions

    1. Web.Config and appSettings tag
      I am storing a database connection string in a key/value pair in the appSettings tag of the web.config file as follows: <appSettings> <add...
    2. ConfigurationSettings Error
      In my WebService I have a method called Download() that creates a dataset. To get my connection string which is located in my web.config file I call...
    3. How Do I get ConfigurationSettings from the calling assembly?
      I'm developing a server control for our intranet. This control is only going to be used in two applications on the server, but they must be...
    4. How: Ampersand in AppSettings value??
      I am wondering how i can put an ampersand character into the value attribute of a key in the appSettings section of my web.config file. If i try to...
    5. appSettings problem!
      Hello! I have one problem with the appSettings on win2k srv machine with framework 1.1. Following line not work anymore (it worked fine with...
  3. #2

    Default Re: ConfigurationSettings.AppSettings Error

    Hello Chris,
    I am sorry that I couldn't get back to you earlier. I am including below a
    code that doesn't return null values. Please let
    me know if this works for you:

    ================
    AppSettings.aspx
    ================
    <%@ Page language="c#" Codebehind="AppSettings.aspx.cs"
    AutoEventWireup="false" Inherits="CustomerDemos.AppSettings" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="AppSettings" method="post" runat="server">
    <asp:Literal id="Literal1" runat="server"></asp:Literal>
    </form>
    </body>
    </HTML>

    ==================
    AppSettings.aspx.cs
    ==================
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Configuration;
    using System.Collections.Specialized;

    namespace CustomerDemos
    {
    /// <summary>
    /// Summary description for AppSettings.
    /// </summary>
    public class AppSettings : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Literal Literal1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    NameValueCollection config = ConfigurationSettings.AppSettings;
    foreach(String Key in config)
    {
    Literal1.Text += "Key: " + Key + "<br>";
    Literal1.Text += "Value:" + config[Key] + "<p>";
    }

    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion
    }
    }


    ==========
    web.config
    ==========
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>

    <system.web>


    <compilation
    defaultLanguage="c#"
    debug="true"
    />


    <authentication mode="Windows" />

    </system.web>
    <appSettings>
    <add key="CoreDBConnection" value="User ID=xx;Password=xxxx;Initial
    Catalog=xxxx;Data Source=x.x.xx.xx" />
    <add key="ListDBConnection" value="User ID=xx;Password=xxxx;Initial
    Catalog=xxxx;Data Source=x.x.xx.x" />
    <add key="RelayInboxQ" value=".\private$\xxbound" />
    <add key="RelaySMTPQ" value=".\private$\yyybound" />
    <add key="RelayWaitQ" value=".\private$\mmm" />
    <add key="relay_xxx" value="Password=xxxx;User ID=xx;Initial
    Catalog=relay_xxx;Data Source=x.x.xx.xx" />
    </appSettings>
    </configuration>

    I hope this will work for you. This sample will print all the keys and the
    values inside the appSettings. It
    didn't find any null values.

    Thanks,
    Bassel Tabbara
    Microsoft, ASP.NET

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    | From: "Chris" <chris.bolyard@softvu.com>
    | References: <OzjeR8JQDHA.3768@tk2msftngp13.phx.gbl>
    <8l3WNxMQDHA.1724@cpmsftngxa09.phx.gbl>
    | Subject: Re: ConfigurationSettings.AppSettings Error
    | Date: Wed, 2 Jul 2003 15:24:29 -0500
    | Lines: 93
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    | Message-ID: <#2qSgcNQDHA.2424@tk2msftngp13.phx.gbl>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: host46-162.discord.birch.net 65.16.46.162
    | Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    | Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:31840
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Thanks for any help
    |
    | As mentioned below we have yet to stress test, but we only store sql
    server
    | connect strings and msmq paths (private queues for now)
    |
    | ConfigurationSettings.AppSettings["RelaySMTPQ"]
    |
    | <add key="RelaySMTPQ" value=".\private$\xxbound" />
    |
    |
    |
    | As mentioned below we have yet to stress test, but we only store sql
    server
    | connect strings and msmq paths (private queues for now)
    |
    |
    | ConfigurationSettings.AppSettings["RelaySMTPQ"]
    |
    | <add key="RelaySMTPQ" value=".\private$\outboundmail" />
    |
    | Here is the entire section
    |
    | <add key="CoreDBConnection" value="User ID=xx;Password=xxxx;Initial
    | Catalog=xxxx;Data Source=x.x.xx.xx" />
    | <add key="ListDBConnection" value="User ID=xx;Password=xxxx;Initial
    | Catalog=xxxx;Data Source=x.x.xx.x" />
    | <add key="RelayInboxQ" value=".\private$\xxbound" />
    | <add key="RelaySMTPQ" value=".\private$\yyybound" />
    | <add key="RelayWaitQ" value=".\private$\mmm" />
    | <add key="relay_xxx" value="Password=xxxx;User ID=xx;Initial
    | Catalog=relay_xxx;Data Source=x.x.xx.xx" />
    |
    |
    |
    |
    |
    | ""Bassel Tabbara [MSFT]"" <basselt@online.microsoft.com> wrote in message
    | news:8l3WNxMQDHA.1724@cpmsftngxa09.phx.gbl...
    | > Hello Chris,
    | >
    | > When you are experiencing this problem? What are you including in the
    | > AppSettings Config file.
    | > Are you using long string? What characters are you using in this
    | > configuration section?
    | > Can you provide some sample when it will fail?
    | >
    | > I am including below a Kb article that you might find useful:
    | >
    | > 311515 HOW TO: Store Data in Application Scope by Using ASP.NET and
    Visual
    | > C#
    | > [url]http://support.microsoft.com/?id=311515[/url]
    | >
    | >
    | > Thanks,
    | > Bassel Tabbara
    | > Microsoft, ASP.NET
    | >
    | > This posting is provided "AS IS", with no warranties, and confers no
    | rights.
    | >
    | >
    | > --------------------
    | > | From: "Chris" <chris.bolyard@softvu.com>
    | > | Subject: ConfigurationSettings.AppSettings Error
    | > | Date: Wed, 2 Jul 2003 08:43:12 -0500
    | > | Lines: 10
    | > | X-Priority: 3
    | > | X-MSMail-Priority: Normal
    | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    | > | Message-ID: <OzjeR8JQDHA.3768@tk2msftngp13.phx.gbl>
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | > | NNTP-Posting-Host: host46-162.discord.birch.net 65.16.46.162
    | > | Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    | > | Xref: cpmsftngxa09.phx.gbl
    | microsoft.public.dotnet.framework.aspnet:31709
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | > |
    | > | Has anybody experience and/or resolved randomly getting NULL back from
    | > | ConfigurationSettings.AppSettings?
    | > | Framework 1.1
    | > |
    | > | We may need to setup a stress test to determine how often this occurs,
    | but
    | > | googling shows there are other cases.
    | > |
    | > | Thanks, Chris
    | > |
    | > |
    | > |
    | >
    | >
    |
    |
    |


    Bassel Tabbara [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139