Results 1 to 6 of 6

Thread: Application settings, Application resources or Registry?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    16

    Application settings, Application resources or Registry?

    Hi,

    Apologies if this is in the the incorrect forum...

    I was wondering if anyone knew the benefits/drawbacks of using either Application settings, Application resources or the good old registry?

    As far as i can tell there are no performance or security benefits.

    Also when it comes to senesitive data such as database connection strings, what is the best way to store these in terms of security?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Application settings, Application resources or Registry?

    Resources are part of your compiled executable so they are only useful for static data. Because the data is within your executable it is safe from tampering.

    Use of application settings is integrated into the Framework so is simple to implement. Settings are stored in the XML config files so they are easily accessible from within the application or they can be hand-edited if that's appropriate.

    The Registry should generally be avoided in .NET applications unless you have a specific need to use it.

    Connection strings can be stored in the config file and encrypted if required.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    16

    Re: Application settings, Application resources or Registry?

    Why should the registry be avoided in .Net? what are the disadvantages?

    also what do you mean by the "config file"? if the resources are compiled as part of the excutable would it be safe to store the connection string here?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Application settings, Application resources or Registry?

    Microsoft recommend against using the Registry because it is getting overloaded and has become unwieldy. .NET has added the configuration system specifically for .NET apps to use to store configuration information. The config file is an XML file stored in the same folder as your assembly. You can add one to your project explicitly if you want but there are many operations that will add one automatically because they need to store data in it, like saving a Data Source connection string or adding application settings.

    It's a bad idea to store the connection string as a resource because changing it would require recompilation.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Application settings, Application resources or Registry?

    Quote Originally Posted by jmcilhinney View Post
    It's a bad idea to store the connection string as a resource because changing it would require recompilation.
    So the best place to store a connection string is... The registry?
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Application settings, Application resources or Registry?

    Quote Originally Posted by Dave Sell View Post
    So the best place to store a connection string is... The registry?
    Is that supposed to be a joke?
    Quote Originally Posted by jmcilhinney
    The Registry should generally be avoided in .NET applications unless you have a specific need to use it.
    Quote Originally Posted by jmcilhinney
    Connection strings can be stored in the config file and encrypted if required.
    Quote Originally Posted by jmcilhinney
    Microsoft recommend against using the Registry because it is getting overloaded and has become unwieldy.
    Quote Originally Posted by jmcilhinney
    .NET has added the configuration system specifically for .NET apps to use to store configuration information.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width