Newbie help with .config

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: raykos (anonymous_at_discussions.microsoft.com)
Date: 03/11/04


Date: Thu, 11 Mar 2004 12:41:09 -0800

Hello all,

    Can't seem to get 'System.Configuration.ConfigurationSettings.AppSettings' to work. What I've done thus far, is just
create a windows app called 'WindowsApplication2'. To this app I used 'Add new Item' and added 'Application configuration
file' and named it 'WindowsApplication2.exe.config'. I then rebuilt the solution. After rebuilding I went to the folder where
my project is and copiled the .config file into the.bin\debug and tried run to cursor to see if I could read the .config
file. Nope. Get an error.

        using System.Configuration;

                static void Main()
                {
                        string test1 = System.Configuration.ConfigurationSettings.AppSettings
                                ["Key1"].ToString();

                        MessageBox.Show(test1);

                        Application.Run(new Form1());
                }

The .config looks like this:

<?xml version="1.0" encoding="utf-8" ?><configuration><appSettings><add key="Key1" value="One" /><add key="Key2" value="Two" /><add key="Key3" value="Three" /></appSettings></configuration>

     When I run to "string test1.." and try to step over I get a:
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication2.exe
Additional information: Object reference not set to an instance of an object.

   Help, what am I missing, doing wrong,etc.?

  Any help appreciated

  TIA,

 Ray K.
 



Relevant Pages

  • Re: Newbie help with .config
    ... I took your .config file directly from your code b/c I couldn't find ... bin folder and the compile again, it should rebuild the exe.config file for ... I've deleted my exe.config and then rebuilt and it works ... Object reference not set to an instance of an ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WARNING: at kernel/trace/ftrace.c:434 ftrace_bug+0xdb/0x2b1() in 2.6.29-rc1-next-200
    ... and a CONFIG to go with it. ... So I didn't see it when I rebuilt without any of my patch stack, ... The entries from 0x815d45f0 to 0x815d4710 are identical to the entries ... was last (executed first) it was ...
    (Linux-Kernel)
  • Re: do I really need "make-kpkg clean"?
    ... >>with changes in config options. ... and so on) are rebuilt. ... > dependency graph that make considers before taking action. ...
    (Debian-User)
  • Re: ZoneAlarm - web access problem
    ... > Any suggestions on what seems to be either a config or ZA problem? ... I would have to say it is something on the rebuilt pc. ... did not unplug the rebuilt box from the hub. ...
    (comp.security.firewalls)
  • Re: Serious Batch Build Bug!!
    ... Unfortunately, I can't attach anything. ... If you currently have a solution with a windows app and at least one ... (Try simply running the debug config, ...
    (microsoft.public.dotnet.languages.csharp)