My working code is below (though many people think it doesn't work): var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Ĭ("AgentID1") Ĭ. The path and name of the configuration file Perhaps this requires reflection, perhaps this requires writing data in two locations.Įither way, I'd rather not have my testers look in both app.config and I want to standardise on a fixed behaviour for all my components that use config (WCF Bindings, Tracing, Log4Net, etc) but as soon as you stop and rerun your application Visual studio replaces the file with your exe. When the system starts up, SVCHOST. Each of these processes hosts a group of services. When you look at the list of running processes in Task Manager, you may see a number of different SVCHOST.EXE processes (as shown below). I understand why this is happening, but I'd like to find a standard way to read/write a config file when debugging and not debugging. Whenever you are running your application in debug mode from visual studio the vshost.exe is executed that is the reason why the file is changing when your code to modify the config file was run. SVCHOST.EXE is a generic host process for services. My testing (code below) shows that ConfigurationManager reads and writes occur to during debugging, and to app.config when running normally. Some answers even recommend using an XMLReader/XMLWriter to do this, which shouldn't be the correct answer since there is a specialized Configuration class for this purpose. However the answers are not consistent, and neither the question nor answer usually indicate that the data may be saved in during debugging. File Summary File Format: CONFIG: Function: Program: Third-Party Software: Version: 1.0.0. We recommend re-loading Third-Party Software to test for the issue. There are many examples of how to read/write app.config in Stack Overflow (and the rest of the Internet). These problems are generally caused by Third-Party Software-related file corruption, or in some cases.
0 Comments
Leave a Reply. |