Specify default WCF endpoint in app.config
When you add a service reference, it creates a "MyServiceClient" class with a standard constructor. If I use the new MyServiceClient () , I get the error: Could not find default endpoint ... If I use the new MyServiceClient ("endpointName") it works.
I would like to specify a default endpoint in app / web.config to be used when I use the default constructor. I know I can put that default name in * .settings and use it throughout my application, but just wondering if there is any built-in way to do this.
source to share
If your client app.config has only one endpoint, then one endpoint will be used.
If yuo has multiple endpoints in your client app.config, you must determine which one to use. There is no mechanism or feature in WCF that designates it as the default "endpoint", and I haven't heard of WCF 4 adding any such feature.
So if you want to have a default endpoint, then yes, you will also need to store the endpoint name in your app.config and get that name programmatically before instantiating the endpoint.
source to share