Newbie help with .config
From: raykos (anonymous_at_discussions.microsoft.com)
Date: 03/11/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: KeyDown in Panel?"
- Previous message: Michael S. Malley: "NotifyIcon Bug, Application.EnableVisualStyles, Application.DoEvents, and Memory Leaks"
- Next in thread: William Ryan eMVP: "Re: Newbie help with .config"
- Reply: William Ryan eMVP: "Re: Newbie help with .config"
- Reply: raykos: "RE: Newbie help with .config"
- Messages sorted by: [ date ] [ thread ]
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.
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: KeyDown in Panel?"
- Previous message: Michael S. Malley: "NotifyIcon Bug, Application.EnableVisualStyles, Application.DoEvents, and Memory Leaks"
- Next in thread: William Ryan eMVP: "Re: Newbie help with .config"
- Reply: William Ryan eMVP: "Re: Newbie help with .config"
- Reply: raykos: "RE: Newbie help with .config"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|