"Click Once" deployment - Changing Configuration File Settings - C# / VB.NET

milani_lucie
milani_lucie used Ask the Experts™
on
Hi,

I have done "Click Once" deployment of my application written in C# / VB.NET. Now i want to change the configuration file settings (Ex: Connection String). I do NOT want to do whole deployment once again, because it is a simple configuration setting. And if i change the configuration settings directly, will it work ? Can you please provide me which file i need to touch, .NET commands & steps for dealing with this situation ?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
.NET Framework 2.0 added a separate configuration section in both Windows Application configuration (App.config) and Web Application configuration (Web.config) file. Developers can use these section to store connection string information such as a connection string name or provider type etc. In the following tutorial I will show you how you can store and retrieve connection string information in .NET Windows Application using C#.
 
The following code shows how you can store connection strings in App.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <connectionStrings>
      <add name="MyDBConnectionString" providerName="System.Data.SqlClient"
            connectionString="Data Source=localhost;Initial Catalog=MySQLServerDB; Integrated Security=true" />
   </connectionStrings>
</configuration>
Once you have saved your connection string in App.config file you can use System.Configuration.ConfigurationManager class to read this connection string in code.

ConnectionStringSettings  conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
ConnectionStringsSettings class provides properties to read connection string settings in your program as following code shows.

string name = conSettings.Name;
string providerName = conSettings.ProviderName;
string connectionString = conSettings.ConnectionString;
Which file you need to amend really depends the initial configuration. Whether the initial programmer used application settings or whatever method for connection string.

If he/she used the application settings, then changing just the connection string there will work.
Most Valuable Expert 2012
Top Expert 2014

Commented:
If you want to change settings for every user from your server, then you will have to redeploy the app. If you want to change settings on the client machines manually, you would need to find out the folder path of click once app from its shortcut, and then go in and change the appname.exe.config file.

Author

Commented:
Not exactly what i want...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial