Alternatively, you may be able to use the RemotingConfiguration.Configure () method. It's in System.Runtime.Remoting, but you don't have to be using remoting to use the method.
Details are hazy, but I remember (a long time ago) being able to use this to load a .config file other than the default. The important thing is that you need to call this method _before_ any part of your code asks for any configuration settings. If the configuration settings are already loaded, I think calls to this method are ignored. This may all be out of date now - I think I did it with .NET 1.0, so I'm not at all sure how 1.1 or 2.0 will behave. It's probably worth experimenting with though. Geoff > -----Original Message----- > From: Discussion of advanced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED] On Behalf Of Eddie Lascu > Sent: 02 January 2007 12:42 > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] Configuration file name as a start up > parameter > > Why don't you rename your cMyConfigFile.config file as a first step of > your > application. The reason why you would need a different name (I presume) > is > to be able to switch from one config file to the other just by > restarting > your service with a different start-up parameter. You could have > > cMyConfigFile1.config > cMyConfigFile2.config > cMyConfigFile3.config > > and every time you restart your service, copy the config file that you > passed in as a start-up parameter and create myapp.exe.config file > (overwrite the existing file, if any). This way you will always have > your > different config files and your assemblies will not need any changes. > Am I missing something? > > Regards, > Eddie > > -----Original Message----- > From: Discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] Behalf Of Georg Jansen > Sent: Saturday, December 30, 2006 3:51 AM > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: [ADVANCED-DOTNET] Configuration file name as a start up > parameter > > > Hi, > > I have an application where I need to provide the name of the > configuration > file as a start up parameter (for example myapp.exe -cMyConfigFile). > The > application is started as a windows service. > > The application uses other assemblies that use the "standard" > System.Configuration.ConfigurationManager.AppSettings["MySetting"], to > retrieve settings from the config file, and it would be best if I did > not > need to rewrite those assemblies. > > So what I need is some kind of method to specify a different > application > config file, and have the framework read from that file instead of the > standard "myapp.exe.config". > > I have been struggling with this for a while, and any help would be > appreciated! > > > Best regards > Georg > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com