|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to reference an external config file in app.configHi!
In .NET20 I would like to reference an external config file from the applicationSettings / My.MySettings chapter in app.config. I have tried to do the same way as I did in .NET1.1, according to: http://weblogs.asp.net/pwilson/archive/2003/04/09/5261.aspx?CommentPosted=true#commentmessage But the external file is never read, or is not overriding the values in the app.config. Best regards, Benjamin Tengelin Hi Benjamin,
According to the .Net SDK, the "file" attribute is indeed an optional attribute of the appSettings section. In addition, the appSettings section and a number of other sections can use an optional "configFile" attribute to specify an external configuration file. The rules for the "configFile" and "file" attributes differe slightly, however. Here is a reference to the appSettings section and the "file" attribute: http://msdn2.microsoft.com/en-us/ms228154.aspx Here is documentation for the "configSource" attribute: http://msdn2.microsoft.com/en-us/system.configuration.sectioninformation.configsource.aspx You may note that you can now set the "RestartOnExternalChanges" attribute when using the configSource attribute. Be sure that you get all the syntax correct. It is probable that the syntax may be slightly different than with .Net 1.1, and it is almost certain that the syntax rules are more strict! -- Show quoteHTH, Kevin Spencer Microsoft MVP Professional Chicken Salad Alchemist I recycle. I send everything back to the planet it came from. "Benjamin" <Benja***@discussions.microsoft.com> wrote in message news:2763BBD7-C601-461B-8DCE-BDD831E83A0E@microsoft.com... > Hi! > > In .NET20 I would like to reference an external config file from the > applicationSettings / My.MySettings chapter in app.config. > > I have tried to do the same way as I did in .NET1.1, according to: > http://weblogs.asp.net/pwilson/archive/2003/04/09/5261.aspx?CommentPosted=true#commentmessage > > But the external file is never read, or is not overriding the values in > the > app.config. > > Best regards, > Benjamin Tengelin Thanks!
It is a good start, but a way to go to have the same flexibility as using the obsolete <appSettings file="YourSettings.config"> because as you can read at my linked web page the additions or overrides in YourSettings.config are merged into app.config only IF (!) YourSettings.config exists, otherwise are only the values in the app.config used. This dynamic is exactly what I want to achive but instead using the preferred applicationSettings/My.MySettings section. I have valuated the information that you areis not at all used, even if a specific item is not included in the YourSettings.config that exists in app.config. configSource seems to be a more ALL or NOTHING approach. Comment? I did loose some words in my sentence. Let me explain what I really want to
achive. We have app.config file that has the URL to the web service, this file is checked in into our file/version control system. And this is the URL that is used from all installed clients around the world. <applicationSettings configSource="CesowWindowsClient.User.config"> <My.MySettings> <setting name="WebService" serializeAs="String"> <value>http://<SERVER>/Service.asmx But we that develops the solution we want to access the web service on our localhost instead of the server. <setting name="CesowWindowsClient_CesowFacade_Service" serializeAs="String"> <value>http://localhost/Service.asmx</value> </setting> But we do not want to checkout/edit the app.config file to make it work for the developers. It should be like that, if a configfile exists on a specific place on the hard drive, these settings should override the settings in the standard app.config. E g app.config <applicationSettings configSource="C:\CesowWindowsClient.User.config"> <My.MySettings> <setting name="WebService" serializeAs="String"> <value>http://<SERVER>/Service.asmx And C:\CesowWindowsClient.User.config haves the localhost URL above. But I can not make this work. |
|||||||||||||||||||||||