Solved

Visual Studio 2010 and Multiple Config Files

Posted on 2011-09-29
3
327 Views
Last Modified: 2012-06-27
I have a project that I am working on, and I have multiple config files for it. It is a WCF project, to be more specific. I would like to be able to choose which config file I would like to use for a compile (whether web.config or app.config). Is it possible to switch back and forth between different config files?
0
Comment
Question by:aceswildab1
  • 2
3 Comments
 
LVL 6

Expert Comment

by:regevha
ID: 36979907
The config file takes effect only in runtime and it can include one or more services, each one with one or more bindings. You can use the following code if you would like the Binding and the EndpointAddress to be dynamic:
// using System.ServiceModel;
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpoint = new EndpointAddress(new Uri("http://localhost:9000/MyService"));
MyServiceClient client = new MyServiceClient(binding, endpoint);

Open in new window

0
 

Author Comment

by:aceswildab1
ID: 37058364
I was wanting to only use the config files and not have to hard code anything in. Is it possible to do this with config files or only hard coding end points in?
0
 
LVL 6

Accepted Solution

by:
regevha earned 500 total points
ID: 37065031
It is not required to hardcode the binding nor the endpoint. You may create a client without specifying endpoint and binding, and the client will use the definitions in app.config
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question