How can I dynamically change a connectionString in the app.config file?
I have an application written with windows forms, c# 3.0 and Linq to Sql. I need to change the connection string when i install the application. How i do this?
When the user installs the program it must show a form with an option to change the connection string if exists or add one if it doesn't.
Check out this question. It has what you need to change values in the app.config dynamically through code.
Write a secondary config file with an appSettings block using the settings from the installer. In your main config file, use the file attribute in appSettings to reference the second config file, like so:
Settings in the secondary config will override any matching keys in the main config.
In your installer:
If you are using a .NET deployment project, can achieve this by using Custom Actions.