By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

System.Configuration.Configuration

P: n/a
Can you tell me how to read and modify a value in the app.config file using
this class?
Thank you very much
Feb 6 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx

If you simply need to read/write data in the appSettings element then you
can use the ConfigurationManager class:

ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx

You may also want to check out Application Settings, new to the 2.0
Framework:

Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much

Feb 7 '07 #2

P: n/a
Hi!

Funny, i am just dealing with a problem related to this.

I cant access the configuration class somehow...

I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...

Any idea?

Regards
Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl...
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx

If you simply need to read/write data in the appSettings element then you
can use the ConfigurationManager class:

ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx

You may also want to check out Application Settings, new to the 2.0
Framework:

Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
>Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much


Feb 8 '07 #3

P: n/a
Hi Martin,

You can't see it or just can't access it? Realize that the Configuration
class has not static method or properties (other than ReferenceEquals,
inherited from Object). It may be the ConfigurationManager class that
you're after.

If you have added a System.Configuration assembly reference to your project,
then I see no reason why the Configuration class wouldn't be visible in the
code editor. You tried a using directive or fully-qualifying the type name
in code?

Also, Configuration is sealed, and so cannot be inherited. If you're trying
to type it after a ":" then Visual Studio may be excluding it from
IntelliSense.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:eP*************@TK2MSFTNGP04.phx.gbl...
Hi!

Funny, i am just dealing with a problem related to this.

I cant access the configuration class somehow...

I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...

Any idea?

Regards
Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl...
>Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx

If you simply need to read/write data in the appSettings element then you
can use the ConfigurationManager class:

ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx

You may also want to check out Application Settings, new to the 2.0
Framework:

Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
>>Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much



Feb 8 '07 #4

P: n/a
Hi!

I have tried to use the folowing.

* Use System.Configuration;
* System.Configuration.Configuration config = xxxxxx; (xxx = other code)

For some darn reason it just wont come up. if i compile i get an error.

I have made sure i have the latest .NET Framework 2 and that the project
uses the .NET 2 Framework.

Regards
Martin
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:eH**************@TK2MSFTNGP02.phx.gbl...
Hi Martin,

You can't see it or just can't access it? Realize that the Configuration
class has not static method or properties (other than ReferenceEquals,
inherited from Object). It may be the ConfigurationManager class that
you're after.

If you have added a System.Configuration assembly reference to your
project, then I see no reason why the Configuration class wouldn't be
visible in the code editor. You tried a using directive or
fully-qualifying the type name in code?

Also, Configuration is sealed, and so cannot be inherited. If you're
trying to type it after a ":" then Visual Studio may be excluding it from
IntelliSense.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:eP*************@TK2MSFTNGP04.phx.gbl...
>Hi!

Funny, i am just dealing with a problem related to this.

I cant access the configuration class somehow...

I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...

Any idea?

Regards
Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl...
>>Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx

If you simply need to read/write data in the appSettings element then
you can use the ConfigurationManager class:

ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx

You may also want to check out Application Settings, new to the 2.0
Framework:

Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much



Feb 8 '07 #5

P: n/a
Ill throw in the compiler error as well:

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

And the declared line is:

public void OpenFile()
{
System.Configuration.Configuration config;
}

(The last Configuration is underlined by the compiler...)

Regards
Martin

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netskrev i
meddelandet news:Oc**************@TK2MSFTNGP02.phx.gbl...
Hi!

I have tried to use the folowing.

* Use System.Configuration;
* System.Configuration.Configuration config = xxxxxx; (xxx = other code)

For some darn reason it just wont come up. if i compile i get an error.

I have made sure i have the latest .NET Framework 2 and that the project
uses the .NET 2 Framework.

Regards
Martin
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:eH**************@TK2MSFTNGP02.phx.gbl...
>Hi Martin,

You can't see it or just can't access it? Realize that the Configuration
class has not static method or properties (other than ReferenceEquals,
inherited from Object). It may be the ConfigurationManager class that
you're after.

If you have added a System.Configuration assembly reference to your
project, then I see no reason why the Configuration class wouldn't be
visible in the code editor. You tried a using directive or
fully-qualifying the type name in code?

Also, Configuration is sealed, and so cannot be inherited. If you're
trying to type it after a ":" then Visual Studio may be excluding it from
IntelliSense.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote
in message news:eP*************@TK2MSFTNGP04.phx.gbl...
>>Hi!

Funny, i am just dealing with a problem related to this.

I cant access the configuration class somehow...

I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...

Any idea?

Regards
Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl...
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx

If you simply need to read/write data in the appSettings element then
you can use the ConfigurationManager class:

ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx

You may also want to check out Application Settings, new to the 2.0
Framework:

Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much
>




Feb 8 '07 #6

P: n/a
Hi Martin,

You're sure that you have referenced the System.Configuration assembly in
your project from the .NET tab?

Try opening the object browser and expand the System.Configuration node.
Can you find the Configuration class in there? (If you can't find the
System.Configuration namespace then the assembly probably isn't referenced
by any of your projects).

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:eR**************@TK2MSFTNGP05.phx.gbl...
Ill throw in the compiler error as well:

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

And the declared line is:

public void OpenFile()
{
System.Configuration.Configuration config;
}

(The last Configuration is underlined by the compiler...)

Regards
Martin

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netskrev i
meddelandet news:Oc**************@TK2MSFTNGP02.phx.gbl...
>Hi!

I have tried to use the folowing.

* Use System.Configuration;
* System.Configuration.Configuration config = xxxxxx; (xxx = other code)

For some darn reason it just wont come up. if i compile i get an error.

I have made sure i have the latest .NET Framework 2 and that the project
uses the .NET 2 Framework.

Regards
Martin
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:eH**************@TK2MSFTNGP02.phx.gbl...
>>Hi Martin,

You can't see it or just can't access it? Realize that the
Configuration class has not static method or properties (other than
ReferenceEquals, inherited from Object). It may be the
ConfigurationManager class that you're after.

If you have added a System.Configuration assembly reference to your
project, then I see no reason why the Configuration class wouldn't be
visible in the code editor. You tried a using directive or
fully-qualifying the type name in code?

Also, Configuration is sealed, and so cannot be inherited. If you're
trying to type it after a ":" then Visual Studio may be excluding it
from IntelliSense.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote
in message news:eP*************@TK2MSFTNGP04.phx.gbl...
Hi!

Funny, i am just dealing with a problem related to this.

I cant access the configuration class somehow...

I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...

Any idea?

Regards
Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl...
Hi,
>
The online documentation and examples should be more than adequate:
>
Configuration Class
http://msdn2.microsoft.com/en-us/lib...iguration.aspx
>
If you simply need to read/write data in the appSettings element then
you can use the ConfigurationManager class:
>
ConfigurationManager Class
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>
You may also want to check out Application Settings, new to the 2.0
Framework:
>
Application Settings Overview
http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
>
--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)
>
"Alberto" <al*****@nospam.eswrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
>Can you tell me how to read and modify a value in the app.config file
>using this class?
>Thank you very much
>>
>
>




Feb 9 '07 #7

P: n/a
Well. that was an experience...

Isn't all assemblies loaded for Visual Studio to use?

When i added it it worked like charm :)

Thanx!

/Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi Martin,

You're sure that you have referenced the System.Configuration assembly in
your project from the .NET tab?

Try opening the object browser and expand the System.Configuration node.
Can you find the Configuration class in there? (If you can't find the
System.Configuration namespace then the assembly probably isn't referenced
by any of your projects).

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:eR**************@TK2MSFTNGP05.phx.gbl...
>Ill throw in the compiler error as well:

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

And the declared line is:

public void OpenFile()
{
System.Configuration.Configuration config;
}

(The last Configuration is underlined by the compiler...)

Regards
Martin

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netskrev i
meddelandet news:Oc**************@TK2MSFTNGP02.phx.gbl...
>>Hi!

I have tried to use the folowing.

* Use System.Configuration;
* System.Configuration.Configuration config = xxxxxx; (xxx = other code)

For some darn reason it just wont come up. if i compile i get an error.

I have made sure i have the latest .NET Framework 2 and that the project
uses the .NET 2 Framework.

Regards
Martin
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:eH**************@TK2MSFTNGP02.phx.gbl...
Hi Martin,

You can't see it or just can't access it? Realize that the
Configuration class has not static method or properties (other than
ReferenceEquals, inherited from Object). It may be the
ConfigurationManager class that you're after.

If you have added a System.Configuration assembly reference to your
project, then I see no reason why the Configuration class wouldn't be
visible in the code editor. You tried a using directive or
fully-qualifying the type name in code?

Also, Configuration is sealed, and so cannot be inherited. If you're
trying to type it after a ":" then Visual Studio may be excluding it
from IntelliSense.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote
in message news:eP*************@TK2MSFTNGP04.phx.gbl...
Hi!
>
Funny, i am just dealing with a problem related to this.
>
I cant access the configuration class somehow...
>
I use the System.Configuration, but for some reason the
System.Configuration.Configuration is not accessible from the
System.Configuration?!? I do have net framework 2 installed...
>
Any idea?
>
Regards
Martin
>
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:OF**************@TK2MSFTNGP05.phx.gbl.. .
>Hi,
>>
>The online documentation and examples should be more than adequate:
>>
>Configuration Class
>http://msdn2.microsoft.com/en-us/lib...iguration.aspx
>>
>If you simply need to read/write data in the appSettings element then
>you can use the ConfigurationManager class:
>>
>ConfigurationManager Class
>http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>
>You may also want to check out Application Settings, new to the 2.0
>Framework:
>>
>Application Settings Overview
>http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)
>>
>"Alberto" <al*****@nospam.eswrote in message
>news:eu*************@TK2MSFTNGP02.phx.gbl.. .
>>Can you tell me how to read and modify a value in the app.config
>>file using this class?
>>Thank you very much
>>>
>>
>>
>
>




Feb 9 '07 #8

P: n/a
Hi Martin,
Isn't all assemblies loaded for Visual Studio to use?
The C# compiler references mscorlib automatically, by default. Visual
Studio may add some references for you to new projects created by a
particular template. For instance, a new WinForms project will have a
reference to System.Windows.Forms.dll. You have to add any references that
Visual Studio doesn't add for you.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:O5*************@TK2MSFTNGP05.phx.gbl...
Well. that was an experience...

Isn't all assemblies loaded for Visual Studio to use?

When i added it it worked like charm :)

Thanx!

/Martin

"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Hi Martin,

You're sure that you have referenced the System.Configuration assembly in
your project from the .NET tab?

Try opening the object browser and expand the System.Configuration node.
Can you find the Configuration class in there? (If you can't find the
System.Configuration namespace then the assembly probably isn't
referenced by any of your projects).

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote
in message news:eR**************@TK2MSFTNGP05.phx.gbl...
>>Ill throw in the compiler error as well:

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

And the declared line is:

public void OpenFile()
{
System.Configuration.Configuration config;
}

(The last Configuration is underlined by the compiler...)

Regards
Martin

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netskrev
i meddelandet news:Oc**************@TK2MSFTNGP02.phx.gbl...
Hi!

I have tried to use the folowing.

* Use System.Configuration;
* System.Configuration.Configuration config = xxxxxx; (xxx = other
code)

For some darn reason it just wont come up. if i compile i get an error.

I have made sure i have the latest .NET Framework 2 and that the
project uses the .NET 2 Framework.

Regards
Martin
"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
news:eH**************@TK2MSFTNGP02.phx.gbl...
Hi Martin,
>
You can't see it or just can't access it? Realize that the
Configuration class has not static method or properties (other than
ReferenceEquals, inherited from Object). It may be the
ConfigurationManager class that you're after.
>
If you have added a System.Configuration assembly reference to your
project, then I see no reason why the Configuration class wouldn't be
visible in the code editor. You tried a using directive or
fully-qualifying the type name in code?
>
Also, Configuration is sealed, and so cannot be inherited. If you're
trying to type it after a ":" then Visual Studio may be excluding it
from IntelliSense.
>
--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)
>
"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.net>
wrote in message news:eP*************@TK2MSFTNGP04.phx.gbl...
>Hi!
>>
>Funny, i am just dealing with a problem related to this.
>>
>I cant access the configuration class somehow...
>>
>I use the System.Configuration, but for some reason the
>System.Configuration.Configuration is not accessible from the
>System.Configuration?!? I do have net framework 2 installed...
>>
>Any idea?
>>
>Regards
>Martin
>>
>"Dave Sexton" <dave@jwa[remove.this]online.comskrev i meddelandet
>news:OF**************@TK2MSFTNGP05.phx.gbl. ..
>>Hi,
>>>
>>The online documentation and examples should be more than adequate:
>>>
>>Configuration Class
>>http://msdn2.microsoft.com/en-us/lib...iguration.aspx
>>>
>>If you simply need to read/write data in the appSettings element
>>then you can use the ConfigurationManager class:
>>>
>>ConfigurationManager Class
>>http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>>
>>You may also want to check out Application Settings, new to the 2.0
>>Framework:
>>>
>>Application Settings Overview
>>http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
>>>
>>--
>>Dave Sexton
>>http://davesexton.com/blog
>>http://www.codeplex.com/DocProject (Sandcastle in Visual Studio
>>2005)
>>>
>>"Alberto" <al*****@nospam.eswrote in message
>>news:eu*************@TK2MSFTNGP02.phx.gbl. ..
>>>Can you tell me how to read and modify a value in the app.config
>>>file using this class?
>>>Thank you very much
>>>>
>>>
>>>
>>
>>
>
>




Feb 9 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.