1

I have two configuration one is "connectionStrings" another is "system.serviceModel" I want to change thous configuration at run time. Here is my configuration :

<connectionStrings>
  <add name="Procesta.serverSideService.Properties.Settings.Cafeteria_Vernier_dbConnectionString"
  connectionString="Data Source=SHUVO0\SQLEXPRESS;Initial Catalog=Cafeteria_Vernier_db;Integrated Security=True"
  providerName="System.Data.SqlClient" />
</connectionStrings>

<system.serviceModel>
 <services>
  <service name="Procesta.serverSideService.ServerSideServices">
    <endpoint address="net.tcp://localhost:9000/ServerSideServices"
              binding="netTcpBinding"
              bindingConfiguration=""
              name="CustomersService_Tcp"
              contract="Procesta.serverSideService.IServerSideServices" />
  </service>
</services>

i want to change connectionString "Data Source=SHUVO0\SQLEXPRESS;Initial Catalog=Cafeteria_Vernier_db;Integrated Security=True" to "Data Source=HASAN589\SQLEXPRESS;Initial Catalog=Cafeteria_Vernier_db;Integrated Security=True"

and address "net.tcp://localhost:9000/ServerSideServices" to "net.tcp://192.168.1.1:9000/ServerSideServices"

Thank`s for help.

Vero009
  • 612
  • 3
  • 18
  • 31

3 Answers3

1

Don't. USe your own config file, and then set this up.... outside the app.config. TONS of advantages from isolating user / install specific settigns from the app.config.

TomTom
  • 61,059
  • 10
  • 88
  • 148
0

I think to be able to change settings during runtime they have to be in User scope, not Application, you can't change that during runtime, and ConnectionString settings are in Application scope by default, and that can't be changed (I don't know about Service settings, though).

Are your settings really "dynamic"? Cant you just assign them during installation, or change during closing your app (and ask the user to "restart the app for changes to take place"?). Or you can add one more, alternative connection string to your settings and change between the two during runtime however you want.

Arie
  • 5,251
  • 2
  • 33
  • 54
0

You can make different targets and use config transformations. E.g. you can make a publish target from your release target and have a specific config for this target that you apply using web config transformation. Check out the top two answers on this q/a: App.Config Transformation for projects which are not Web Projects in Visual Studio 2010?

Community
  • 1
  • 1
Andreas
  • 6,447
  • 2
  • 34
  • 46