Posted by: Mark Wilkinson | July 8, 2009

Dynamic Connection String to WCF Host

Another issue I came across was needing a way to dynamically connect to a WCF host without using the app.config file (which in all examples I see, they put the connection string in the app.config).

In code you can specify the endpoint address like so, with the “localhost:8008″ being the tcp address you want:

InstanceContext instanceContext = new InstanceContext(this);
client = new Service1Client(instanceContext);

client.Endpoint.Address = new EndpointAddress(“net.tcp://localhost:8008/Service1″);


Leave a response

Your response:

Categories