为什么不是.NET"应用程序设置"存储在注册表中?注册表、应用程序、不是、QUOT

2023-09-02 02:08:06 作者:霸氣總裁

一些时间回到上个世纪九十年代,微软推出了Windows注册表。应用程序可以存储在不同荨麻疹设置。有荨麻疹的应用范围和用户特定范围,而这些被放置在合适的位置,使漫游配置文件工作正常。

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.

在.NET 2.0及以上,我们有这个东西叫做应用程序设置。应用程序可以使用它们来存储在XML文件中的设置,应用的.exe.config和用户的.config文件。这些都是应用范围和用户特定范围,而这些被放置在合适的位置,使漫游配置文件都能正常工作。

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.

听起来很熟悉?什么是这些应用程序设置是通过XML文件的支持,而不是简单地使用注册表中的原因是什么?这难道不正是注册表的目的是什么?

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?

我能想到的唯一原因是,注册表是Windows专用和.NET试图与平台无关。这是否是一个(或在的)原因,或是否有我俯瞰其他方面的考虑?

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?

推荐答案

我不认为这是一个答案,我认为这是一个组合:

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

在注册表中创建它的时候看上去像一个好主意,储存在同一个地方,所有的程序都设置为反对前通常使用的.ini文件。当时这个增强的性能小.ini文件读取缓慢的硬盘驱动器是昂贵的,一个注册表文件有所提高性能。这就是现在不同,因为硬盘是远远快,越来越多的设置都被抛在注册表使其成为系统的负担。你会看到这个,如果你安装和卸载很多的Windows程序中也开始放慢脚步,最终你可能最终重新格式化。 在一个不正确写入注册表,即使在当前用户的设置可以毁掉你的系统。 在注册表没有帮助Xcopy部署计划没有具体的code处理缺少的注册表项。这包括删除程序,只需删除该文件夹,在许多情况下, 在更大的权限,可以根据需要,如果需要到注册表进入安装应用程序 .config文件很容易让默认应用程序和用户设置,可以由最终用户修改在程序第一次运行 允许.NET在其他系统上可能没有运行操作系统特定的code。这在某种程度上可以看出与Silverlight和独立存储。 通过使用独立存储的应用程序和用户安全性更高 在给微软的可能性的方式在未来有一个管理code唯一的操作系统没有太多旧的依赖。想想框架的任何操作系统和管理code之间的一层。 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.