configuration-files

How to read values from multiple Configuration file in c# within a single project?

筅森魡賤 提交于 2019-11-27 15:18:42
问题 Here in my project I have two application configuration files called app.config and accessLevel.config . Now using the OpenExeConfiguration I was able to access the app.config.exe file but not the accessLevel.config . Please help on this. The main reason I have 2 config files is to show the difference and make the code simple. I need to read the values from the accessLevel.config in my C# code. Tried the below code but no use: System.Configuration.Configuration config = ConfigurationManager

How to use .NET configuration files (app.config, settings.settings) to save and restore all application data?

坚强是说给别人听的谎言 提交于 2019-11-27 15:12:19
问题 Although there are a lot of posts about .net config files, I believe that my requirements do not allow for any of the solutions proposed (or I don't understand the process enough to make it work for me). The situation is that I have a Windows Forms application (could just as well be another app) which binds certain user input fields (e.g. IP Address), as well as form properties (window size, etc) to application settings (in the Properties->Settings area). From what I understand, these

Reload configuration settings from an external config file during run-time

こ雲淡風輕ζ 提交于 2019-11-27 14:46:36
问题 I'm writing a game server in C# and would like to reload or refresh settings from a config file while the server is running. Ideally I would like to save the settings in an XML file, have the ability to edit the file while the game server is running and then send the server the command to reload the settings from the file. I know I can use a database to do this as well, but the game server is fairly small and I think it would be more practical to just save settings in a flat-file. I will have

Get the App.Config of another Exe

孤者浪人 提交于 2019-11-27 14:30:46
问题 I have an exe with an App.Config file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities. The question is how can I access the app.config property in the exe from the wrapper dll? Maybe I should be a little bit more in my questions, I have the following app.config content with the exe: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myKey" value="myValue"/> </appSettings> </configuration> The question is how to

Can ConfigurationManager retain XML comments on Save()?

允我心安 提交于 2019-11-27 13:46:08
问题 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 config again and update it. cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); var setting = cfg.AppSettings.Settings[keyName]; setting.Value = newValue;

Use an INI file in C on Linux

前提是你 提交于 2019-11-27 13:39:33
问题 Is there a standard way of reading a kind of configuration like INI files for Linux using C? I am working on a Linux based handheld and writing code in C. Otherwise, I shall like to know about any alternatives. Final update: I have explored and even used LibConfig. But the footprint is high and my usage is too simple. So, to reduce the footprint, I have rolled out my own implementation. The implementation is not too generic, in fact quite coupled as of now. The configuration file is parsed

WCF Error - The maximum message size quota for incoming messages (65536) has been exceeded [duplicate]

*爱你&永不变心* 提交于 2019-11-27 13:34:41
This question already has an answer here: The maximum message size quota for incoming messages (65536) has been exceeded 2 answers My Setup: ASP.NET client hosted in IIS Express WCF Service hosted in Console Application Running Visual Studio.NET 2012 in Admin mode I am trying to return 2 List objects from a WCF service. My setup WORKS FINE when I return just 1 List objects. But when I return 2 List objects I get the error: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding

How to load a separate Application Settings file dynamically and merge with current settings?

情到浓时终转凉″ 提交于 2019-11-27 13:20:43
There are questions pertaining to reading settings from a separate config file and others similar to it, but my question is specific to application property settings (i.e. <MyApplication.Properties.Settings> - see XML file below) and how to load them dynamically. I tried the method in this post , which involved refreshing the entire appSettings section of the main config file, but my adaptation threw exceptions because I wasn't replacing the appSettings section: var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); // Have tried the other

Read custom configuration file in C# (Framework 4.0)

我与影子孤独终老i 提交于 2019-11-27 12:02:42
I am developing an application in C# under Framework 4.0. In my application I would like to create separate configuration file that is not the app.config file. The configuration file contains custom configuration sections we developed for the product. I don't want to reference this file from the app.config using the configSource. I want to load it at runtime and read it's content. An example to what I mean is the log4net that allow you to write the configuration in the log4net.config file. Can anyone help how to do that without writing code that mimcs the code that exists in the framework ?

How can I make a .NET class library read its own configuration file?

こ雲淡風輕ζ 提交于 2019-11-27 11:41:16
问题 I have a .NET class library that provides a set of helper functions that are used by several Web Services. This class library must store a single setting, specifically, a connection string, which need not be seen by the Web Services themselves, since they all must query the same datbase. Unfortunately, .NET provides no means to easily read a DLL's app.config file. The only "easy" solution would be to store the connection string in every single Web Service configuration file, which is