ConfigurationManager in Beta2

  • Thread starter Thread starter Michael Debus
  • Start date Start date
M

Michael Debus

Hi, I try to read a value from app.config file using this code:

string
s=System.Configuration.ConfigurationManager.AppSettings["server"].ToString();

I got the compiler error:

Error 1 The type or namespace name 'ConfigurationManager' does not exist in
the namespace 'System.Configuration' (are you missing an assembly
reference?) .

A reference to System.Configuration.dll is added to the project.

My System.Configuration.dll has Version 2.0.50215.44. I there a newer
version ?

Thanks
Michael
 
I think it should be
string s=System.Configuration.Configuration.AppSettings["server"];
 
Hello,
System.Configuration.ConfigurationSettings.AppSettings["server"];
works.

but i'v got a warning:
Warning 2 'System.Configuration.ConfigurationSettings.AppSettings' is
obsolete: 'This method is obsolete, it has been replaced by
ConfigurationManager.AppSettings'

i tryed to follow Microsofts suggestion to use ConfigurationManager.

Michael


Alex Feinman said:
I think it should be
string s=System.Configuration.Configuration.AppSettings["server"];


--
Alex Feinman
---
Visit http://www.opennetcf.org
Michael Debus said:
Hi, I try to read a value from app.config file using this code:

string
s=System.Configuration.ConfigurationManager.AppSettings["server"].ToString();

I got the compiler error:

Error 1 The type or namespace name 'ConfigurationManager' does not exist
in the namespace 'System.Configuration' (are you missing an assembly
reference?) .

A reference to System.Configuration.dll is added to the project.

My System.Configuration.dll has Version 2.0.50215.44. I there a newer
version ?

Thanks
Michael
 
Should work in 50215 are you sure you did add areference to
System.Configuration.dll!.
Note that you might get better answers when posting to
http://forums.microsoft.com

Willy.

Michael Debus said:
Hello,
System.Configuration.ConfigurationSettings.AppSettings["server"];
works.

but i'v got a warning:
Warning 2 'System.Configuration.ConfigurationSettings.AppSettings' is
obsolete: 'This method is obsolete, it has been replaced by
ConfigurationManager.AppSettings'

i tryed to follow Microsofts suggestion to use ConfigurationManager.

Michael


Alex Feinman said:
I think it should be
string s=System.Configuration.Configuration.AppSettings["server"];


--
Alex Feinman
---
Visit http://www.opennetcf.org
Michael Debus said:
Hi, I try to read a value from app.config file using this code:

string
s=System.Configuration.ConfigurationManager.AppSettings["server"].ToString();

I got the compiler error:

Error 1 The type or namespace name 'ConfigurationManager' does not exist
in the namespace 'System.Configuration' (are you missing an assembly
reference?) .

A reference to System.Configuration.dll is added to the project.

My System.Configuration.dll has Version 2.0.50215.44. I there a newer
version ?

Thanks
Michael
 
Perhaps my suggestion is stupid, but why don't you use the
Properties.Settings class ? It directly maps values in the app.config and
you can read/write using this kind of code :

string s = Properties.Settings.Default.Server;
 
Back
Top