?
Solved

Visual Studio 2010 and Multiple Config Files

Posted on 2011-09-29
3
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

762 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