Solved

Visual Studio 2010 and Multiple Config Files

Posted on 2011-09-29
3
324 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now