configurationmanager

Getting a StringCollection out of AppSettings through the configuration manager

I am accessing my assembly's configuration like this: ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = Assembly.GetExecutingAssembly().Location + ".config"; Configuration conf = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); AppSettingsSection appSettings = conf.App...

Change in AppSettings needs restart my Application how can I avoid?

I'm using C# .NET 2.0 Windows Application. and I'm using app.config for my Application Settings. but change in AppSettings doesn't reflected runtime, it Needs Application to be restarted. How can I avoid it. Here is my code snippet I used to read and write the Application Settings. I'm reading the Setting like this string temp = Co...

In Shared Addin Extensibility how to get Application Configuration File?

In case of VSTO this AppDomain.CurrentDomain.SetupInformation.ConfigurationFile This Returns the Configuration file of the Executing Plugin, while shared add-in Returns False Configuration File as AppDomain returns d:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE instead of the Assembly of the Plugin. My Question is how can I get th...

Binding to ConfigurationSection

I just converted all my settings from AppSettings to ConfigurationSections. It definitely cleaned things up, but I'm having difficulties with the preferences window. I want to use bindings in my WPF window. Should I store each of the ConfigurationSections in a dependency property and bind to the ConfigurationSection's properties? Sh...

How do you instruct NUnit to load an assembly's dll.config file from a specific directory?

If an assembly contains an app.config file, ConfigurationManager will load it as long as it is in the same directory as the NUnit project that is executing through NUnit-Gui. To illustrate consider the following folder structure. + TestFolder testProject.nunit + AssemblyAFolder assemblyA.dll assemblyA.dll.config + A...

Visual Studio: Configuration Manager missing

I'm using Microsoft Visual Studio Team System 2008 Team Suite. The "Configuration Manager" menu item is missing for me. I've assigned a keyboard shortcut to the Configuration Manager, but it doesn't have any effect (actually, it produces a "ding" sound). How do I get the Configuration Manager to work for all projects? ...

How to return a verbatim string from ConfigurationManager.AppSetting["settingname"].ToString()

I am using the ConfigurationManager.AppSetting["blah"].ToString() method to get the path to the folder that contains the files I'm needing. But I'm throwing an UnsupportedFormatException on the path when it tries to use Directory.GetFiles(path). The returning value has the escape characters included and I'm not sure how to keep it from ...

ConfigurationSettings.AppSettings is empty, throws null exception

I have a class like this: public class RxNormFolderMgr { // properties public string RxNormFolder { get { return ConfigurationSettings.AppSettings["rootFolder"].ToString(); } } } When I try to use it like this: public class TestRxNormFolderManager : ColumnFixture { public string RxNormFolder() { RxNormFolderMg...

Can not get a reference to ConfigurationManager

I simply can not get Visual Studio 2005 to find the System.Configuration.ConfigurationManager class. Here is the code: using System.Configuration; ... x = ConfigurationSettings.AppSettings["MySetting"] // The name 'ConfigurationManager' does not exist in the current context x = System.Configuration.ConfigurationManager.AppSettings["M...

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 application: ConfigurationManager.AppSettings["SomeStringOverHere"]; I try to build the application and I get the error: The name 'Configuratio...

Migrating a WinForms (C#) APP settings to a .config file.

Hi Guys, I want to migrate the settings file I am currently using to appconfig file. At the moment I am trying to make a copy of it but so far I cannot even get it to write to the file using the Config' Manager. What I need to do is first create the file and then write to it and finally of it already exists, update it!. Seems pretty si...

Can ConfigurationManager retain XML comments on Save()?

I've written a small utility that allows me to change a simple AppSetting for another application's App.config file, and then save the changes: //save a backup copy first. var cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); cfg.SaveAs(cfg.FilePath + "." + DateTime.Now.ToFileTime() + ".bak"); //reopen the original c...

C# Reading Configuration settings

I have a C# class library A which has some configuration settings in its App.config I access them with Method1() { string connectionString = ConfigurationManager.AppSettings["ConnectionString"]; } But when I call Method 1() from my ASP Web project B, it cannot find the configurations settings in the Class library A Any idea what is ...

How to load application settings to NHibernate.Cfg.Configuration object?

How to load application settings to NHibernate.Cfg.Configuration object by using System.Configuration.ConfigurationManager from App.config? ...

Changing App.config at Runtime

I'm writing a test winforms / C# / .NET 3.5 application for the system we're developing and we fell in the need to switch between .config files at runtime, but this is turning out to be a nightmare. Here's the scene: the Winforms application is aimed at testing a WebApp, divided into 5 subsystems. The test proccess works with messages b...

Why does ConfigurationManager.OpenMappedExeConfiguration have an extra connection string not in the file?

I'm unit testing my config file for a win forms application. In the LocalTestRun.testrunconfig I set it to copy the app.config. I've checked the Environment.CurrentDirectory while the test was running and the file doesn't have this extra connection string either. This is the test method: [TestMethod] public void Configuration_Connec...

Create valid .config from Custom ConfigurationElement classes

Does anyone have a good technique for generating a valid xx.config file after you have finished creating your public class XXXConfigurationElement : ConfigurationElement { [ConfigurationProperty("blabhblahblah", IsRequired=true)] public YYYConfigElement Foobar { get { return (YYYConfigElement )base["blabhblahblah"]...

Differences in behavior between System.Web.Configuration.WebConfigurationManager and System.Configuration.ConfigurationManager

Hi, I had some trouble on a test server with an ASP.NET website. I goofed, and had the home directory of the Default Web Site pointed to the wrong place. When I tried: ConfigurationManager.ConnectionStrings["connectionString"]; it returned null, but System.Configuration.Configuration rootWebConfig = System.Web.Configuratio...

How to access app.config/web.config for the current Application?

Although in name this question is similar to this and this, it's not. I'm currently developing a library that may require some custom configuration depending on the user's desire. I have created a custom configuration section, and everything works just fine. However, when I was debugging I noticed that the configuration section const...

Using ConfigurationManager to write to an external config file?

I've not been able to find any easy reference on this: I have a web.config file that specifies <appSettings file="someotherfile.config"/> to put settings in an external file. That means that someotherfile.config is not a "valid" configuration file, as it doesn't follow the full tree format, it just contains the appSettings subtree. Is ...