Re: Proper place for custom CONFIG file

From: Vagif Abilov (vagif_at_online.no)
Date: 01/08/05


Date: Sat, 8 Jan 2005 09:36:33 +0100

Richard,

Thank you for your suggestions. It's a good idea to use XmlSeializer,
althouh parsing such simple structures into NameValueCollection is also a
very simple thing (but XmlSerializer approach is more elegant indeed).
Regarding a place to store the settings, I am now convinced that I should
stay away from Framework directories. For the project of our type (the
system is configured per machine, not per user, it's a server application),
I decided to place config file inside <Program Files>\<Common
Files>\<Company Name> folder. The folder <Common Files> contains various
common settings and components for different companies, so in case we have
stuff to be shared by several of our applications, it feels a good place.

Then I wrote a class that extends functionality of ConfigurationSettings
class (although it can't inherit from it, because the original class is
sealed and only contains static methods). The new class, in addition to
AppSettings property, also has AssemblySettings and MachineSettings
properties that will return respective parts of common configuration file.
Such approach resulted in minimum changes in our code and looks like a
natural extension of standard .NET class.

Vagif

"Richard Grimes [MVP]" <read my sig> wrote in message
news:epKjW$P9EHA.1260@TK2MSFTNGP12.phx.gbl...
> Vagif Abilov wrote:
>> We have a set of applications and assemblies that belong to one
>> project. Some of the configuration settings are supposed to be shared
>> between various assemblies on the same machine. After long
>> discussions we finally decided that the best alternative for us is to
>> create a custom configuration file <OutProject>.config and place it
>> in a common directory. Then we can write our own configuration parser
>> that will return NameValueCollection settings.
>
> You could use XmlSerializer to serialise a serializable object in one go
> to an XML file, there's no need to write a parser.
>
>> There seems to be two good places to install such file:
>> <Windows>\Microsoft.NET\Framework\<CurrentVersion> and
>> <Windows>\Microsoft.NET\Framework\<CurrentVersion>\CONFIG. Both of
>> them contain several configuration files. My first impression was
>> that the latter one is the best (since it's called CONFIG), however
>> it contains only system specific configurations files like
>> machine.config. All application-based config files are located one
>> level up, inside <Windows>\Microsoft.NET\Framework\<CurrentVersion>.
>
> No No No. Don't pollute the system folders.
>
>> Do you know what is the best practice?
>
> Here's some suggestions.
>
> 1) Store the file in a folder with the project name under the user's
> profile local application settings folder. The advantage of this idea is
> that you guarantee that the user of your app will have access to the file
> (note that administrators may use NTFS ACLs on a machine to restrict the
> folders that a user can access). The disadvantage is that every user has
> their own copy (so deployment is complicated) and you no longer have XCOPY
> deployment.
>
> 2) Organise your applications in a folder structure, eg:
>
> Project_Folder
> |
> |----App 1
> |
> |----App 2
>
> Put the common settings file in Project_Folder. The advantage is that you
> know where the file is, you have one copy for all users. The disadvantage
> is that you are not guaranteed access to this folder, but the
> administrator will be able to ensure that.
>
> Richard
> --
> www.richardgrimes.com
> my email evpuneqt@zicf.bet is encrypted with ROT13 (www.rot13.org)
>
>



Relevant Pages

  • Re: Configuration Error : Web.Config [No Relevant Source Line]
    ... it didn't inherit the wwwroot default security settings. ... configuration file required to service this request. ... I Copy the "integrate" folder, the folder where my code is, and ... web admin tool to configure settings for your application. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: make desktop read only...good policy?
    ... Microsoft Steady State. ... User Configuration - Windows Settings - Folder Redirection ...
    (microsoft.public.windows.terminal_services)
  • Re: Proper place for custom CONFIG file
    ... Some of the configuration settings are supposed to be shared ... > between various assemblies on the same machine. ... Store the file in a folder with the project name under the user's profile ...
    (microsoft.public.dotnet.framework)
  • RE: Cannot make Redirected My Documents Available Offline
    ... specifically enabled the offline folder settings, ... >>> up under the user configuration windows settings but I cannot find any ...
    (microsoft.public.windows.server.active_directory)
  • Re: Forcing Save Location
    ... > click on the correct folder icon in the Places bar. ... > [[This enables changing the location when a common dialog is opened. ... > Any settings made under User Configuration are saved in HKEY_CURRENT_USER. ...
    (microsoft.public.windowsxp.basics)