Questions tagged [configurationmanager]

In the .Net framework, ConfigurationManager is a built-in object that provides access to configuration files.

The ConfigurationManager class includes members that enable you to perform the following tasks:

Read a section from a configuration file.

Read and write configuration files as a whole.

Support configuration tasks, such as: section information, property information etc...

In addition to working with existing configuration information, you can create and work with custom configuration elements by extending the built-in configuration types such as the ConfigurationElement, ConfigurationElementCollection, ConfigurationProperty, and ConfigurationSection classes.

594 questions
208
votes
18 answers

AppSettings get value from .config file

I'm not able to access values in configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var clientsFilePath = config.AppSettings.Settings["ClientsFilePath"].Value; // the second line gets…
Matt
  • 8,195
  • 31
  • 115
  • 225
187
votes
8 answers

How to find path of active app.config file?

I'm trying to finish this exception handler: if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null) { string pathOfActiveConfigFile = ...? throw new ConfigurationErrorsException( "You either forgot to set the connection…
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
168
votes
9 answers

How to check if an appSettings key exists?

How do I check to see if an Application Setting is available? i.e. app.config and in the…
bitcycle
  • 7,632
  • 16
  • 70
  • 121
112
votes
4 answers

What's the difference between the WebConfigurationManager and the ConfigurationManager?

What's the difference between the WebConfigurationManager and the ConfigurationManager? When should I use one over the other? UPDATED I just looked at the WebConfigurationManager, and for some reason, you can't access the connection strings as you…
John B
  • 20,062
  • 35
  • 120
  • 170
98
votes
9 answers

ConfigurationManager.AppSettings - How to modify and save?

It might sound too trival to ask and I do the same thing as suggested in articles, yet it doesn't work as expected. Hope someone can point me to the right direction. I would like to save the usersettings per AppSettings. Once the Winform is closed I…
Houman
  • 64,245
  • 87
  • 278
  • 460
76
votes
14 answers

Java configuration framework

I'm in the process of weeding out all hardcoded values in a Java library and was wondering what framework would be the best (in terms of zero- or close-to-zero configuration) to handle run-time configuration? I would prefer XML-based configuration…
Steen
  • 6,573
  • 3
  • 39
  • 56
76
votes
3 answers

Does ConfigurationManager.AppSettings[Key] read from the web.config file each time?

I'm wondering how the ConfigurationManager.AppSettings[Key] works. Does it read from the physical file each time I need a key? If so, should I be reading all the app settings of my web.config in a cache and then read from it? Or does ASP.NET or IIS…
The Light
  • 26,341
  • 62
  • 176
  • 258
71
votes
8 answers

How to get the values of a ConfigurationSection of type NameValueSectionHandler

I'm working with C#, Framework 3.5 (VS 2008). I'm using the ConfigurationManager to load a config (not the default app.config file) into a Configuration object. Using the Configuration class, I was able to get a ConfigurationSection, but I could not…
Liran B
  • 711
  • 1
  • 5
  • 4
70
votes
4 answers

Error: The name 'ConfigurationManager' does not exist in the current context

I have included the following statement in my Visual C# Console Application (Visual Studio 2005 .NET 2.0 Framework) using System.Configuration; and I am using the following statement in my…
zack
  • 7,115
  • 14
  • 53
  • 63
66
votes
5 answers

Loading System.ServiceModel configuration section using ConfigurationManager

Using C# .NET 3.5 and WCF, I'm trying to write out some of the WCF configuration in a client application (the name of the server the client is connecting to). The obvious way is to use ConfigurationManager to load the configuration section and write…
DavidWhitney
  • 4,290
  • 4
  • 24
  • 30
57
votes
9 answers

System.Configuration.ConfigurationManager not available?

In a VS2005 C# project I have added a reference to System.configuration. In the object browser, I can see the System.Configuration.ConfigurationManager. In Intellisense System.Configuration only has the old ConfigurationSettings, and not…
kpollock
  • 3,899
  • 9
  • 42
  • 61
45
votes
6 answers

ConfigurationManager.AppSettings Caching

We know that IIS caches ConfigurationManager.AppSettings so it reads the disk only once until the web.config is changed. This is done for performance purposes. Someone at: http://forums.asp.net/p/1080926/1598469.aspx#1598469 stated that .NET…
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
37
votes
4 answers

ConfigurationManager.OpenExeConfiguration - loads the wrong file?

I have added multiple app.config (each with a differet name) files to a project, and set them to copy to the output directory on each build. I try and access the contents of each file using this: System.Configuration.Configuration o =…
user9659
  • 901
  • 2
  • 9
  • 19
36
votes
6 answers

ConfigurationManager not found

I am new to VS 3.5 and I am writing a console app that needs to pull some key values from the app.config file. I have: Imports System.Configuration and I am trying to reference ConfigurationManager.AppSettings but this generates an error: Name…
DeveloperM
  • 1,129
  • 7
  • 17
  • 30
35
votes
9 answers

The problem with NUnit and app.config

When i run a simple test on connection to DB check i receive an error in NUnit: [Test] public void TestConn() { string connectionString = ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString; SqlConnection connection =…
Mike
  • 659
  • 2
  • 7
  • 9
1
2 3
39 40