Reputation: 857
I have an application that is run from an application server. I want to beable to change the connection string that the application uses from outside of the application (I do not want the user to do this, and I do not want to use a command line argument, but I want to save the information without having to re-compile)
The application is .net 4.0
I notice that visual studio creates a file called appname.exec.config. Can I add a tagged entry to this file then read it from the .net (C#) application? I don't want the program to edit the file. Instead I want an administrator to edit the file and the program to read it.
I prefer not to use some custom xml file that gets packaged, perferring instead to use a file like appname.exe.config that is automatically deployed by Visual Studio.
Upvotes: 0
Views: 1043
Reputation: 7097
Within Visual Studio you'll see under your project a 'Settings.settings' file. This is where things such as connection strings and other configuration info is stored. You can also add additional fields to this file. If your scope is set as 'Application' then these are settings that CANNOT be changed at runtime, which is exactly what you are looking for. Instead someone would need to open up the XML file and edit it directly to make a change for the next time your application runs.
http://msdn.microsoft.com/en-us/library/a65txexh%28v=vs.100%29.aspx
Upvotes: 1