J
jman
I am trying to understand ConfigurationManager and why I cannot get
any of my Application Settings using
ConfigurationManager.AppSettings["MySetting"]. I am not having
compiler/build errors, its just that I am not getting my application's
settings/values. Can anyone help me?
I create a new C# Windows Forms project in VS2005 for .NET 2.0
Include reference to System.Configuration under references
Go to Project -> Properties, then the "Settings" side-tab
Add a string setting "MySetting" (Scope = Application) with value
"test"
Then I add some source code to the constructor for the default
"Form1":
using System.Configuration ( near the top )
string s1 = WindowsApplication1.Properties.Settings.Default.MySetting;
string s2 = ConfigurationManager.AppSettings["MySetting"];
Now, when stepping under the debugger I would expect that s1 == s2,
but in fact s1 is "test" (expected) and s2 is null (unexpected).
What am I doing wrong? How can I use ConfigurationManager to read the
string value of the application-scope setting MySetting?
any of my Application Settings using
ConfigurationManager.AppSettings["MySetting"]. I am not having
compiler/build errors, its just that I am not getting my application's
settings/values. Can anyone help me?
I create a new C# Windows Forms project in VS2005 for .NET 2.0
Include reference to System.Configuration under references
Go to Project -> Properties, then the "Settings" side-tab
Add a string setting "MySetting" (Scope = Application) with value
"test"
Then I add some source code to the constructor for the default
"Form1":
using System.Configuration ( near the top )
string s1 = WindowsApplication1.Properties.Settings.Default.MySetting;
string s2 = ConfigurationManager.AppSettings["MySetting"];
Now, when stepping under the debugger I would expect that s1 == s2,
but in fact s1 is "test" (expected) and s2 is null (unexpected).
What am I doing wrong? How can I use ConfigurationManager to read the
string value of the application-scope setting MySetting?