Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2007

Tip: Looking for answers? Try searching our database.

How to reference an external config file in app.config

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benjamin - 19 Jun 2006 13:13 GMT
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#c
ommentmessage


But the external file is never read, or is not overriding the values in the
app.config.

Best regards,
Benjamin Tengelin
Kevin Spencer - 19 Jun 2006 14:43 GMT
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.configs
ource.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!

Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

> Hi!
>
[quoted text clipped - 10 lines]
> Best regards,
> Benjamin Tengelin
Benjamin - 20 Jun 2006 08:20 GMT
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?
Benjamin - 20 Jun 2006 11:57 GMT
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.
Arkiliknam - 14 Aug 2007 03:46 GMT
Did you ever find a way of doing this?

I know in <appSettings> it is possible using the file="fileName.config"
attribute, but the current project is making use of .NET 2.0's
<applicationSettings> instead.

I can't, however find an equivalent to the <appSettings>'s file attribute in
<applicationSettings>.

Thanks,
Andre

> I did loose some words in my sentence. Let me explain what I really want to
> achive.
[quoted text clipped - 30 lines]
>
> But I can not make this work.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.