Understanding ConfigurationSettings
-
Ok, so I know I'm missing something very basic here but I am having a problem understanding how ConfigurationSettings work. I've looked at the various examples but still can't get it to work for me. I have a Windows application ... application name testapp. I've created a configuration file named testapp.exe.config and copied the file into (in this case) the bin\debug directory along with the EXE file. The config file looks like the following... copied from one of the examples: In my code I have the following statement. string appName = ConfigurationSettings.AppSettings["Application Name"]; What I get is appName = null and the config file is removed form the debug\bin directory. So, 1st, should the config file be being deleted..if so, are the actual settings stored someplace? and 2nd, what am I missing by not being able to read the value for "Application Name" give the above code and config file. Thanks for the help Neil Lamka neil@meetingworks.com
-
Ok, so I know I'm missing something very basic here but I am having a problem understanding how ConfigurationSettings work. I've looked at the various examples but still can't get it to work for me. I have a Windows application ... application name testapp. I've created a configuration file named testapp.exe.config and copied the file into (in this case) the bin\debug directory along with the EXE file. The config file looks like the following... copied from one of the examples: In my code I have the following statement. string appName = ConfigurationSettings.AppSettings["Application Name"]; What I get is appName = null and the config file is removed form the debug\bin directory. So, 1st, should the config file be being deleted..if so, are the actual settings stored someplace? and 2nd, what am I missing by not being able to read the value for "Application Name" give the above code and config file. Thanks for the help Neil Lamka neil@meetingworks.com
Hi, This could help: Add a file named "app.config" to the project and compile your solution. Visual Studio .NET will automagically search for a file with that name (app.config) inside your project and create an output file to bin/debug (in this case), then, if you need to change the contents of that config file, modify app.config and it will be reflected on the output file. If you change the output file (when I say "output file" it means "testapp.exe.config") directly it will be overwritten by VS.NET on the next build. Hope this helps. (if I wasn't clear, please tell me and I will try to be :)) Andres Manggini. Buenos Aires - Argentina.
-
Ok, so I know I'm missing something very basic here but I am having a problem understanding how ConfigurationSettings work. I've looked at the various examples but still can't get it to work for me. I have a Windows application ... application name testapp. I've created a configuration file named testapp.exe.config and copied the file into (in this case) the bin\debug directory along with the EXE file. The config file looks like the following... copied from one of the examples: In my code I have the following statement. string appName = ConfigurationSettings.AppSettings["Application Name"]; What I get is appName = null and the config file is removed form the debug\bin directory. So, 1st, should the config file be being deleted..if so, are the actual settings stored someplace? and 2nd, what am I missing by not being able to read the value for "Application Name" give the above code and config file. Thanks for the help Neil Lamka neil@meetingworks.com
It should work. Works for me. Make sure the spelling is correct. The AppSettings are case sensitive.