configurationmanager

how can i clear the configurationmanager cache for connectionstrings

I am trying to change the database name in the connectionstring located in the App.Config of our servicehost at runtime and restart it afterwards connecting to another database. This works fine, but only if the application is shut down for multiple seconds. Shutting down the application for several seconds seems to clear the cache of th...

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 = new SqlConnection(connectionString); connection.Open(); Assert.AreEqual(Connectio...

.Net Custom Configuration Section and Saving Changes within PropertyGrid

If I load the My.Settings object (app.config) into a PropertyGrid, I am able to edit the property inside the propertygrid and the change is automatically saved. PropertyGrid1.SelectedObject = My.Settings I want to do the same with a Custom Configuration Section. Following this code example (from here http://www.codeproject.com/KB/vb/...

Calling Save on a Configuration obj with a custom sectiongroup of type NameValueSectionHandler

I've got aConfiguration object that I can easily read and write settings from and call Save(ConfigurationSaveMode.Minimal, true) on and that typically works just fine. However, I now have a config file that has a custom sectionGroup defined of type System.Configuration.NameValueSectionHandler (I didn't write that part and I can't chan...

Cannot access app.config or settings.settings data

I have a .Net 3.5 application that needs to load a string from settings.settings or app.config. I made sure I have a reference to ConfigurationManager but a very simple call from form load value returns null. Here is the code: void LoadSettings() { // I expect to get from my app.config or settings.settings // Settings file s...

How to Write to a User.Config file through ConfigurationManager?

I'm trying to persist user settings to a configuration file using ConfigurationManager. I want to scope these settings to the user only, because application changes can't be saved on Vista/Win 7 without admin privileges. This seems to get me the user's configuration, which appears to be saved here in Win 7 ([Drive]:\Users\[Username]\A...

How to avoid "The name 'ConfigurationManager' does not exist in the current context" error?

I am using VS2008. I have a project connect with a database and the connection string is read from App.config via ConfigurationManager. We are using L2E. Now I added a helper project, AndeDataViewer, to have a simple UI to display data from the database for testing/verification purpose. I don't want to create another set of Entity Data...

How to make ConfiguratioManager read a config file other than app.config?

Hi, I need to parse a config file that is situated in another project. I know that ConfigurationManager reads the app.config file by default (right?) how to make it read that particular config file? Thank you ...

How to parse app.config using ConfigurationManager?

I was using a certain method for parsing my app.config file. Then I was told that using ConfigurationManager is better and simpler. But the thing is I don't know how to do it with ConfigurationManager. My original code looked like this: XmlNode xmlProvidersNode; XmlNodeList xmlProvidersList; XmlNodeList xmlTaskFactoriesList;...

Winforms connection strings from App.config

I have a Winforms app that I am developing in C# that will serve as a frontend for a SQL Server 2005 database. I rolled the executable out to a test machine and ran it. It worked perfectly fine on the test machine up until the last round of changes that I made. However, now on the test machine, it throws the following exception immediate...

ConfigurationManager Class

How do you use the COnfigurationManager class to read and write to the settings file? ...

C# assembly > app settings > how to check if one exists?

How do I check to see if an Application Setting is available? i.e. app.config ==> <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="someKey" value="someValue"/> </appSettings> </configuration> [code] if (ConfigurationManager.AppSettings.ContainsKey("someKey")) { // Do Something }else{ // ...

When is using the <appSettings> section preferable to a custom configuration section?

When creating my application's or library's configuration, I generally prefer using a custom configuration section over the <appSettings> section for the following reasons. Framework serialization to a user-defined configuration object; each config value has an appropriate type Configuration values may be validated against type and val...

Can't pull out the connection string from the configuration manager

I know I just missing something simple, but when I try pulling the connection string from the ConfigurationManager, I always get null. I have System.configuration added as a reference In the source file I have using System.Configuration; using MySql.Data; using MySql.Data.MySqlClient; .... _connStr = ConfigurationManager.ConnectionStr...

How to get the values of a ConfigurationSection of type NameValueSectionHandler

Hello, 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 an ConfigurationSection, but i could not find a way to get the values of that section. in the config, the Configuratio...

ConfigurationManager looking for different files on different systems

I'm using configuration manager in the simplest way: Read: ConfigurationManager.AppSettings["Foo"] Write: Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["Foo"].Value = value; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("a...

mod_mono question: Could not resolve the name 'ConfigurationManager'

Hello, I'm running mod_mono 2.4.4 on Ubuntu and I'm finding that I've had to go through my VB files and add "imports System.Configuration" to all of them to resolve the name error. This was not necessary in mod_aspdotnet on the Windows side. I have, however, run into one error of which I can't find the source: System.Web.Co...

ConfigurationManager keeps getting Machine.config connection string.

I have a c# assembly that uses the app.config to store its database connection string. When debugging the application I noticed that the connection to the database kept failing because the ConfigurationManager kept returning the machine.config connection string: data source=.\SQLEXPRESS; Integrated Security;.... I added <clear/> before...

C# Configuration Manager

I have the following code: using System.Configuration; namespace test { public partial class MyService : ServiceBase { public static ReadConnectionStrings() { ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings; However, it doesn’t recognise Conf...

wpf - Get values from App Config file

Hi All, How to get values from App.Config. Code: <configuration> <appSettings> <add key="ShowRoomCode" value="1000"/> <add key="FolderPath" value="D:\\Images\\Book\\"/> </appSettings> </configuration> string imageFolderPath = ConfigurationManager.AppSettings["FolderPath"]; But it returns null value. Config file is in t...