none
Registry vs app.config RRS feed

  • Question

  • All,

    In working the design for a re-write of an application (from C++ to C#), we have decided that we wish to use app.config as opposed to the registry. Every developer in my company says "well, yeah", like I just said 2+2=4. However, our "product owners" aren't so sure and want to know why we will be "wasting" the time to convert everything (all 5 settings) from the registry to a config file (yes, I'm a little annoyed).

    Anyway, I've got a few links (the registry article on Wikipedia is nice) but I was hoping someone on this forum might now of a more detailed "registry vs app.config" discussion. And, since I am allegedly an adult, mature, responsible, software professional, I would also like to see arguments AGAINST using the app config file.

    Thanks a lot,
    Chris Snyder, Stumbling through code one day at a time If your question was answered, please mark it.
    Tuesday, July 21, 2009 3:13 PM

Answers

  • I'd say by far the best advantages to the app.config file versus the registry settings are ease of accessibility, as well as portability. 

    If you're needing to change a setting in the registry, you'd better do it right.  Should you get it wrong, you could potentially cause extensive damage to your operating systema and how it functions.  If you screw up the app.config, you're only messing up the single program. 

    Also, portability.  Copying an app.config file, should a database connection string change, or something like that, is far easier than going from computer to computer to install a new registry setting, which would require extracting the original settings, and running it on each and every computer.  An app.config can simply be distributed with your .NET application, which can literally be deployed by copying the assemblies and the app.config to a folder somewhere, then running the executable.  Using the registry will take more time, and isn't really something you want your users poking through anyways. 

    Also, clean uninstall.  Deleting an app.config is far easier and safer than removing registry keys.

    As for disadvantages, the only disadvantage I can think of is in the event that you want some more obfuscation, and if you want to protect your settings from the users a little bit, the registry is more difficult to get to.  This may be something to consider, but in the end, the user can still get to it, and you'd need to beware of any damage they may cause in the process. 
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF MSDN Forums Client
    Tuesday, July 21, 2009 3:19 PM
  • Well, I don't have any arguments against the app config. Hopefully someone else will provide those.

    There are several reasons I like using an app.config:

    1) The built-in code to access an app.config from .NET is very full-featured and easy to use.

    2) You can install the application without having to create registry entries.

    3) You can remove the install without having to worry about removing registry entries.

    4) You don't have to worry about access permissions to the registry (like from Vista).

    Hope this helps get the discussion started ...
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    Tuesday, July 21, 2009 3:20 PM

All replies

  • I'd say by far the best advantages to the app.config file versus the registry settings are ease of accessibility, as well as portability. 

    If you're needing to change a setting in the registry, you'd better do it right.  Should you get it wrong, you could potentially cause extensive damage to your operating systema and how it functions.  If you screw up the app.config, you're only messing up the single program. 

    Also, portability.  Copying an app.config file, should a database connection string change, or something like that, is far easier than going from computer to computer to install a new registry setting, which would require extracting the original settings, and running it on each and every computer.  An app.config can simply be distributed with your .NET application, which can literally be deployed by copying the assemblies and the app.config to a folder somewhere, then running the executable.  Using the registry will take more time, and isn't really something you want your users poking through anyways. 

    Also, clean uninstall.  Deleting an app.config is far easier and safer than removing registry keys.

    As for disadvantages, the only disadvantage I can think of is in the event that you want some more obfuscation, and if you want to protect your settings from the users a little bit, the registry is more difficult to get to.  This may be something to consider, but in the end, the user can still get to it, and you'd need to beware of any damage they may cause in the process. 
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF MSDN Forums Client
    Tuesday, July 21, 2009 3:19 PM
  • Well, I don't have any arguments against the app config. Hopefully someone else will provide those.

    There are several reasons I like using an app.config:

    1) The built-in code to access an app.config from .NET is very full-featured and easy to use.

    2) You can install the application without having to create registry entries.

    3) You can remove the install without having to worry about removing registry entries.

    4) You don't have to worry about access permissions to the registry (like from Vista).

    Hope this helps get the discussion started ...
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    Tuesday, July 21, 2009 3:20 PM
  • Thanks to the both of you. The permissions issue is the one that I think will push it over the edge.

    Chris Snyder: The opinions and statements in this post do not reflect the opinions and statements of YOUR boss.
    Tuesday, July 21, 2009 3:56 PM
  • Regarding point 4): True, you no longer have problems with registry access permissions; but when using app.config, you will have permission problems with accessing the installation folder of your program. Unprivileged user normally do not have access to the "Program Files" folder or any subfolders.

    - Frank
    Friday, August 28, 2009 9:04 AM
  • I have some more points to add in addition to what has already been said by different people here

    1.Content in App.config can be protected using RSA Protected configuration providers available in .Net framework

    2.App.config is a XML based hirerarical tree structure database which follows standards understod by .Net and which can be accessed like objects by .Net Code unlike registry data.

    Cheers
    TicArch

    -----------------------------------------------------------------------------------------------------------------
    If it answers your query, please don't forget to mark this as answer

     

     

    Friday, August 28, 2009 11:37 AM