Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't .NET "application settings" stored in the registry?

Some time back in the nineties, Microsoft introduced the Windows Registry. Applications could store settings in different hives. There were hives for application-wide and user-specific scopes, and these were placed in appropriate locations, so that roaming profiles worked correctly.

In .NET 2.0 and up, we have this thing called Application Settings. Applications can use them to store settings in XML files, app.exe.config and user.config. These are for application-wide and user-specific scopes, and these are placed in appropriate locations, so that roaming profiles work correctly.

Sound familiar? What is the reason that these Application Settings are backed by XML files, instead of simply using the registry? Isn't this exactly what the registry was intended for?

The only reason I can think of is that the registry is Windows-specific, and .NET tries to be platform-independent. Was this a (or the) reason, or are there other considerations that I'm overlooking?

like image 762
Thomas Avatar asked Apr 08 '10 13:04

Thomas


People also ask

Where are .NET application settings stored?

It is in a folder with your application's name in Application Data folder in User's home folder (C:\documents and settings\user on xp and c:\users\user on Windows Vista).

Which file is used to store application level settings in .NET core project?

The project system stores application settings in two XML files: an app. config file, which is created at design time when you create the first application setting. a user.

Where is the application settings?

From the Home screen, tap the Apps icon (in the QuickTap Bar) > the Apps tab (if necessary) > Settings .

What is app settings in asp net?

The appsettings in Asp.net core have different configuration sources as shown below. appsettings.json File. Environment Variable. User Secrets. Command Line Arguments.


3 Answers

Taking a dependency on the registry prevents XCOPY Deployment.

like image 103
Jim Counts Avatar answered Oct 12 '22 04:10

Jim Counts


I don't think it is one answer I think it's a combination:

  • The registry at the time of creating it looked like a good idea to store all settings for all programs in one place as oppose to the .ini files generally used before. At the time this increased performance as small .ini file reads from slow hard drives were costly, a single registry file somewhat increased performance. This is now different as hard drives are far faster and more and more settings have been dumped in the registry making it a burden on the system. You will see this if you install and uninstall lots of programs in windows it begins to slow down and eventually you probably end up reformatting.
  • An incorrect write to the registry even in the current user settings can ruin your system.
  • The registry doesn't help xcopy deployment of programs without specific code to handle lack of registry keys... This includes removing programs by simply deleting the folder in many cases
  • Greater permissions can be needed to install an application if it needs access to the registry
  • A .config file easily allows default application and user setting which can be modified on first run of the program by the end user
  • Allows .NET to potentially run on other systems without OS specific code. This can somewhat be seen with Silverlight and isolated storage.
  • Greater security through the use of Isolated Storage for the application and users
  • Gives Microsoft the possibility way in the future to have a managed code only OS without many old dependencies. Think of the framework as a layer between any OS and the managed code.
like image 26
PeteT Avatar answered Oct 12 '22 06:10

PeteT


Another reason is that in order to edit the registry you would have to have higher amounts of permissions. If you are just editing an app config file you would only need to have rights to that file.

like image 15
Avitus Avatar answered Oct 12 '22 04:10

Avitus