user.config file

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Can a user.config file be used in console and desktop apps to override the
app.config settings in a similar way to how a user.config file can override
a web.config? Thanks in advance.

Mark
 
Sorry to sound dense, but I've never heard of a "user.config" file?
perhaps you could shed some light? If you have an app.config file in your
solution, when compiled, this gets moved to the executable directory and is
automatically renamed by the IDE to
<yourappname>.exe.config
When an .NET executable is run, it looks for a file with this naming
convention automatically, loads and parses it.
The <appSettings> section values (for example) are then all available as a
NameValueCollection in

System.Configuration.ConfigurationSettings.AppSettings["keyName"]... etc.
HTH
Peter
 
I appreciate the reply. We've been using a user.config file in our web apps
for quite some time using the directions at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch4.asp.
(Do a text search on the page for "user.config".) The article's language
implies that you can use these user.config files to override all application
configuration files, but I wanted to confirm this was in fact common
practice.

Thanks in advance.

Mark

Peter Bromberg said:
Sorry to sound dense, but I've never heard of a "user.config" file?
perhaps you could shed some light? If you have an app.config file in your
solution, when compiled, this gets moved to the executable directory and
is automatically renamed by the IDE to
<yourappname>.exe.config
When an .NET executable is run, it looks for a file with this naming
convention automatically, loads and parses it.
The <appSettings> section values (for example) are then all available as a
NameValueCollection in

System.Configuration.ConfigurationSettings.AppSettings["keyName"]... etc.
HTH
Peter

Mark said:
Can a user.config file be used in console and desktop apps to override
the app.config settings in a similar way to how a user.config file can
override a web.config? Thanks in advance.

Mark
 
Back
Top