Solved

Visual Studio 2010 and Multiple Config Files

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

13 Experts available now in Live!

Get 1:1 Help Now