configurationmanager

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 out the data I need. var serviceModelSection = ConfigurationManager.GetSection("sys...

Is there a way to get a System.Configuration.Configuration instance based on arbitrary xml?

I'm trying to unit test a custom ConfigurationSection I've written, and I'd like to load some arbitrary configuration XML into a System.Configuration.Configuration for each test (rather than put the test configuration xml in the Tests.dll.config file. That is, I'd like to do something like this: Configuration testConfig = new Configura...

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 config-files, but it's not essential. Please do only reply if you have practical experience with a fram...

Where does ConfigurationManager ConnectionStrings get its value?

In my ASP.NET application I have a web.config file. In the web.config file I have a connection string... <connectionStrings> <add name="HRDb" connectionString="xxxxx" providerName="System.Data.SqlClient" /> </connectionStrings> Yet, when I retrieve this value using ConfigurationManager.ConnectionStringsp["HRDb"], I get the my old ...

ConfigurationManager.AppSettings Caching doubt

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 Framework doesn't do the same for app.config, but it reads from the disk for every request. Bu...

C# ConfigurationManager.GetSection could not load file or assembly

Hi all, I am stuck! this seems really daft but I can not see where I am going wrong. I am creating a 2.0 C# ASP.NET website. I am trying to use a custom section in the web.config file with: DatabaseFactorySectionHandler sectionHandler = ConfigurationManager.GetSection("DatabaseFactoryConfiguration") as DatabaseFactorySectionHandler;...

How can I set a network connection to use the AES encryption method on a Windows Mobile device?

I am trying to configure a network connection using ConfigurationManager.ProcessConfiguration, with the configuration file as specified in the MSDN docs. I can create a connection, and configure all of the settings correctly except for the encryption type. No matter what I choose, it is always set to TKIP. I need to set it to AES, which ...

App.config and ConfigurationManager

Hi, If I call the OpenMappedExeConfiguration() method and specify a config file (filemap) as a parameter, does this mean that the ConfigurationManager will use the newly specified config file from that point onwards and ignore app.config? I know that ConfigurationManager looks for app.config by default, but because the OpenMappedExeCon...

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 do in the ConfigurationManager (like an array). Can anyone tell me why MS made it like ...

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 string, or " + "you're using a unit test framework that looks for "+ "the...

Do I have to derive from ConfigurationSection to support per-user settings?

I'm playing around with .NET's configuration support (the ConfigurationManager class and related support classes). I would like to write an application that, once installed: Has default settings in foo.exe.config (in Program Files). The user may later override the settings with nondefault values which should be persisted. The user's p...

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 ConfigurationManager. My code System.Configuration.ConfigurationManager.AppSettings["MySetting"]...

How do I give my .ASHX access to ConfigurationManager.ConnectionStrings?

I have included the same files that other pages have that use it but for some reason it's just not finding it. How do I include access to it? ...

Open other program's configuration files

I have a program A, it also have an app.config file where I have added some keys like server address, username and password for connecting to a server. It is a console application. Now I want to make a UI which I have done. In that UI I want to modify the content of app.config of program A. How do I do that? Here is what I tried, I cop...

How to persist app.config through ClickOnce updates using ConfigurationManager?

This question describes my problem exactly, except I'm using a custom configuration section in app.config with ConfigurationManager, so the solution presented there doesn't apply... Basically, my problem is that when ClickOnce updates the application, it installs into a different directory with the new app.config, thereby erasing any ch...

How can I write to my own app.config using a strongly typed object?

The following code has two flaws, I can't figure out if they are bugs or by design. From what I have seen it should be possible to write back to the app.config file using the Configuration.Save and according to http://www.codeproject.com/KB/cs/SystemConfiguration.aspx the code should work. The bugs are shown in the source below and appe...

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 = ConfigurationManager.OpenExeConfiguration(@"app1.config"); The code runs, but o.HasFile ends up Fals...

Forcing ConfigurationManager to reload all sections

I am writing a configuration system in which the app.config file is dynamically constructed from various config fragments distributed across multiple locations. The system currently works as follows: Bootstrapper builds configuration file. Bootstrapper initializes new AppDomain with new config file as the configuration file. As a resul...

Can someone provide a quick App.config/Web.config tutorial?

I've used these two configuration files many times before, but I've never taken the time to fully understand how they really work. As most people do, I understand the basics in how to call WebConfigurationManager.AppSettings["key"] to get config values. Here are some questions I came up with: What happens when you reference a configu...

How can I get ConfigurationManager to load application settings from multiple files?

I'm writing applications that interoperate with a third-party application. This application exposes an API to developers via methods in a DLL. Some time ago, the vendor of this app started integrating their own .NET components into their program, and when they did, they decided that their components should use the ConfigurationManager ...