Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2003, 04:27 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using multiple config files

Hi,

I need to be able to change between configuration files easily. The best way I think is to use multiple links to my application which supply the config filename on the command line.

I tried the following code:
Code:
public static void Main(string[] args)
{
    if (args.Length > 0)
        AppDomain.CurrentDomain.SetupInformation.ConfigurationFile = args[0];

    // Continued...
}
But the value of the ConfigurationFile property did not change so I looked in the Help:
Quote:
quote:This property cannot be changed after the AppDomain has finished its first bind.
Why is that and how can I get around it?


Hoping for ideas...
Johan
 
Old October 6th, 2007, 04:04 PM
Authorized User
 
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

The other way is to look into the ConfigurationManager class, which has static methods to load configuration files dynamically. There is OpenExeConfig(string) and OpenWebConfig(string).

Regards,

Dom





Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Multiple files in Multiple tables Versi Suomi Access 6 June 1st, 2005 08:47 AM
Programatically reading CONFIG files jeffreymsloan@msn.com Linux 2 September 23rd, 2004 10:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.