I have a project that needs to be deployed on multiple servers. Its the same code, only the endpoints are different. Currently, I have to do the following steps:
1) Configure the service reference to point to the correct server
2) Comment out the current server, uncomment the next server (a local parameter for the binding):
//private string serverName = @"http://server1/service.asmx";
//private string serverName = @"http://server2/service.asmx";
//private string serverName = @"http://server3/service.asmx";
private string serverName = @"http://server4/service.asmx";
....
ServiceClass.ServiceClassSoapClient Mgr = new ServiceClass.ServiceClassSoapClient (basicHttpBinding, new EndpointAddress(serverName));
3) Rebuild
4) Publish
There are many (16) servers that I need to do this to, and it is taking a LONG time to manually do this to all of them. Is there a way to do this automatically?
If all you need to do is to store a string which is system-dependent, why not use the built in Application Settings? This stores data on a per-system (or per-user) basis in AppData which is accessible via the My.Settings object.
http://msdn.microsoft.com/en-us/library/a65txexh.aspx
http://msdn.microsoft.com/en-us/library/c9db58th.aspx
For example, you would create a string
type application setting called serverName
and at run-time you could configure this from within your application by reading/writing to My.Settings.serverName
. The value of My.Settings.serverName
is then stored for each system independently and returns a value unique to that system (or user) depending on where your application is running and who is running it.