debugging - WCF: Dynamic address for service reference on client -


Actually, I have an application that needs to use the WCF service (Calculator. Svc). While debugging, my local machine is being served, but in the service the service is being hosted on an IIS server.

Debug address: http: // localhost / MyProj / Services / Calculator. Svc
Address: http://www.mycompany.com/Services/ Calculator.svc

If I do not add a service reference and build service by hand, it is no longer an issue. But, if I add a service reference to my localhost address, how do I change it dynamically during release mode?


Note: I know that I can make a new calculator client and feed in my own binding and endpoint address, but is this the right way to do it?
  Calculator client client; #if, not compulsive binding = new basic HttpBinding ("MyConfig"); Endpoint Addresser Remote Edender = New Endpoint Address ("http://www.mycompany.com/Services/Calculator.svc"); Client = New Calculator Client (Binding, Remote Address); #else Client = New Calculator Client (); #endif   

Is this an easy way or the more appropriate way to do this?

Actually, you have two options:

1) your creation / deployment Change the value in the script in app.config .

2) Use the same address for both. On your Dev Machine this can be setup by adding an entry to your local host at www.mycompany.com pointing to your HOSTS file. After that you set up a web site in the IIS for host header www.mycompany.com and serve the project from there.

Comments