Avatar of milani_lucie
milani_lucie
Flag for United States of America asked on

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

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
C#Visual Basic.NET

Avatar of undefined
Last Comment
milani_lucie

8/22/2022 - Mon
ukerandi

.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;
ASKER CERTIFIED SOLUTION
Anuradha Goli

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
adriankohws

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.
Nasir Razzaq

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
milani_lucie

ASKER
Not exactly what i want...