2

I'm using a webservice in my wpf application. and set it's URL Behavior to Dynamic, so I have an entry in app.config file like below :

<MyApp.Properties.Settings>
  <setting name="MyApp_WebReference_OnlineUsersService" serializeAs="String">
    <value>http://192.168.35.28/OnlineUsersService.asmx</value>
  </setting>
</MyApp.Properties.Settings>

I need to change server address dynamically, for example from 192.168.35.28 to 192.168.35.26.
Question is : how can I change the contents of <value> tag at runtime?

thanks alot :)

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Mahdi Rashidi
  • 1,359
  • 3
  • 18
  • 33

1 Answers1

1

Have you tried this?

var service = new MyApp.OnlineUsersService();
service.Url = "http://192.168.35.28/OnlineUsersService.asmx";

If what you're actually doing is specifying the url for a different path then I'd suggest using config transformation (App.Release.Config) to change the url before packaging.

Naeem Sarfraz
  • 7,360
  • 5
  • 37
  • 63