ConfigurationManager in Beta2

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
 
A

Alex Feinman [MVP]

I think it should be
string s=System.Configuration.Configuration.AppSettings["server"];
 
M

Michael Debus

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
 
W

Willy Denoyette [MVP]

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
 
F

Fabien Bezagu

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top