none
Where to store application settings ? RRS feed

  • Question

  •  

    Hi

     

    I am writing an application where I have to store the application settings.

    Which one is the best way to store application settings and why ?

    Windows Registry

    An XML File.

     

    Regards,

    Haris

     

    Monday, June 9, 2008 6:21 AM

Answers

  • No to registry - MS recommends limiting registry access to user applications.  My guess probably 2+ versions, registry may not even exist in the same form we know of today.

     

    Yes to XML File - I assume this is a .NET application.  Then your app.config file is an XML file.  There is a good amount of robust and rich API set to manage information in app.config file.

     

    Yes to Database - Other than connection information, you could store all the app settings information in a databse.  I usually dont use this as a practice, but many others would recommend and use this.  Nothing wrong in that.

     

    Monday, June 9, 2008 2:55 PM
  • Just add an App.Config to your file. That is what that is specifically for. Either for configuration settings or connection string settings.

    Thursday, July 3, 2008 10:34 PM

All replies

  • No to registry - MS recommends limiting registry access to user applications.  My guess probably 2+ versions, registry may not even exist in the same form we know of today.

     

    Yes to XML File - I assume this is a .NET application.  Then your app.config file is an XML file.  There is a good amount of robust and rich API set to manage information in app.config file.

     

    Yes to Database - Other than connection information, you could store all the app settings information in a databse.  I usually dont use this as a practice, but many others would recommend and use this.  Nothing wrong in that.

     

    Monday, June 9, 2008 2:55 PM
  •  

    I agree with Kannan, Storing the settings in Registry is history. 

    The introduction of Web.Config and App.Config is the way to go, they ease maintenance and helps in deploying your application in various environment.  You can add custom tags to Web.Config as well as App.config and you can programmtically read them or extend them...

     

    Monday, June 9, 2008 4:07 PM
  • Apart from Application Configuration file we also have to concept of Application Settings (which is implemented as xml file on a per user/application basis).
    Wednesday, June 11, 2008 12:36 PM
  • You can set the scope of a setting in a settings file by application/user.  The registry has a performance overhead that is dependant on each machine (i.e. the amount of stuff in the registry).

     

    You may find this article useful; http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx

     

    It describes the different types of settings and how to use them.

     

    One potential issue with the app.config, settings and web.config files is that it is not secure.  Potential attacks are made easier because application information is in an obvious place so you don't have the security through obscurity 'advantage' of the registry.

    Monday, June 30, 2008 1:56 PM
  • You could encrypt sensitive information (like connection string information of a database) in the app and web.config file.  Enterprise library block does a pretty good, if you use ent lib's config block and security block.

     

    I would still not use registry.

    Wednesday, July 2, 2008 5:58 PM
  • I agree - I wouldn't use the registry for the reasons in the previous posts but I think security issues are often overlooked. 

     

    I have seen many application that give away too much internal detail in settings files that could be used maliciously.  When choosing where to store settings it is also useful to consider whether they should be encrypted.

     

    If you have a lot of user settings storing them in a database on the client is also an option but is probably overengineering the majority of applications.

     

    I think the options are windows registry, xml file (including .net setting file, app.config and web.config), and databases. 

     

    I would rule out in the majority of cases.

    Thursday, July 3, 2008 11:19 AM
  • Just add an App.Config to your file. That is what that is specifically for. Either for configuration settings or connection string settings.

    Thursday, July 3, 2008 10:34 PM
  • Hi GajaKannan,

       Can you please point me to a MS article that recommends that a user use the config file rather than the registry? I am trying to look for one but haven't come across any. In you post you mentioned "MS recommends limiting registry access to user applications". If you could direct me to the appropriate MS article, I would really appreciate it.

    Thank you.

    sincerely,

    Aditya

    Monday, February 9, 2009 4:24 PM
  • For application settings, why would you use the registry nowadays? That is what config files are specifically for..

    You can read some articles about that:
    http://msdn.microsoft.com/en-us/library/1xtk877y(VS.80).aspx
    http://www.codeproject.com/KB/cs/SystemConfiguration.aspx
    http://www.codeproject.com/KB/aspnet/ConfigSections.aspx
    http://msdn.microsoft.com/en-us/library/ms184658(VS.80).aspx

    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Edited by JohnGrove Tuesday, February 10, 2009 2:16 AM `
    Tuesday, February 10, 2009 2:12 AM