System.Configuration.Configuration

A

Alberto

Can you tell me how to read and modify a value in the app.config file using
this class?
Thank you very much
 
D

Dave Sexton

Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/library/system.configuration.configuration.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/library/system.configuration.configurationmanager.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
 
M

Martin Arvidsson, Visual Systems AB

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
 
D

Dave Sexton

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.
 
M

Martin Arvidsson, Visual Systems AB

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
 
M

Martin Arvidsson, Visual Systems AB

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 said:
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 said:
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 said:
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.com> skrev i meddelandet
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/library/system.configuration.configuration.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/library/system.configuration.configurationmanager.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)

Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much
 
D

Dave Sexton

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 said:
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 said:
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 said:
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)

in message 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.com> skrev i meddelandet
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/library/system.configuration.configuration.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/library/system.configuration.configurationmanager.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)

Can you tell me how to read and modify a value in the app.config file
using this class?
Thank you very much
 
M

Martin Arvidsson, Visual Systems AB

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 said:
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 said:
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 said:
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.com> skrev i meddelandet
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)

in message 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.com> skrev i meddelandet
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/library/system.configuration.configuration.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/library/system.configuration.configurationmanager.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)

Can you tell me how to read and modify a value in the app.config
file using this class?
Thank you very much
 
D

Dave Sexton

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 said:
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 said:
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 said:
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" <[email protected]> skrev
i meddelandet 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.com> skrev i meddelandet
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" <[email protected]>
wrote in message 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.com> skrev i meddelandet
Hi,

The online documentation and examples should be more than adequate:

Configuration Class
http://msdn2.microsoft.com/en-us/library/system.configuration.configuration.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/library/system.configuration.configurationmanager.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)

Can you tell me how to read and modify a value in the app.config
file using this class?
Thank you very much
 

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