WCF/WF - dynamic add wcf service reference in vs2010

Asked By Pratik Asthana on 22-Mar-11 11:50 AM
Hi All,
I have created WCF Application in vs2010 and using it in window application .
i have added WCF service reference using "Add Web service Reference" from visual stuio.

i want to do it by programming.

Please Help
Robbe Morris replied to Pratik Asthana on 22-Mar-11 12:05 PM
You can change the url to the web service at runtime.  You just create a new instance of your service class:

var bind = new BasicHttpBinding();
   bind.SendTimeout = TimeSpan.FromMinutes(3);

var endPoint = new EndpointAddress(url);
var proxy = new NameOfYourWebReferenceClientClassGoesHere(bind, endPoint);

return proxy;

Pratik Asthana replied to Robbe Morris on 23-Mar-11 01:17 PM
Thanks Dear :-)
its working fine for me.
sagar replied to Pratik Asthana on 20-Sep-11 02:54 AM
 i am using windows and wcf application. every time i am doing any modifications in wcf (.svs file) after that go to windows application here i am manually adding "update service reference". but here i want code for dynamically updating service reference.