.net - mscorlib.dll 和 System.dll

标签 .net assemblies

为什么 MS 最初决定维护这两个独立的核心库?也许他们考虑到了一些可扩展性问题,但现在我从未见过任何类型的应用程序不需要两者。有人有这方面的内幕消息吗?这并不重要,但多年来一直在我的脑海里。

PS。我知道这两个库中有什么,我知道区别 - 我是 Reflector 的忠实粉丝:) 只是想知道两者的分离有什么实际用途。

最佳答案

我在 CLR/BCL 团队工作,刚刚回复了您的电子邮件。粘贴如下:

Jared's answer on Stack Overflow is right on. mscorlib.dll is tightly bound to the CLR for the reasons he mentions. Note that mscorlib.dll itself doesn't contain any native code (as Scott suggests), but there are many places where it needs to call directly into the CLR. As such, the CLR and mscorlib must be versioned together.

System.dll on the other hand is not tightly bound to the CLR (it doesn't require any calls into the runtime). We consider System.dll to be at a higher layer than mscorlib.dll. Having these assemblies in two separate layers allows for more flexibility, making it easier to version System.dll separately from the CLR/mscorlib.dll version (if we wanted to do so). We could, in theory, make changes and add functionality to System.dll without revving the CLR/mscorlib version. The separation also makes it easier to manage dependency rules between components in these different layers.

As Scott mentions, it does seem like there's a lot of "optional" stuff in mscorlib. This is mainly for historical reasons and because some things are just needed by other things. For example, there's no technical reason why System.IO.IsolatedStorage needs to be in mscorlib, but that's just where it happened to be added in 1.0, before we really thought about such versioning/layering concerns. Also, List is in mscorlib because other code in mscorlib has a need for a basic list collection.

Long term we'd like to reduce the amount of "optional" stuff in mscorlib as much as possible. Either by pushing stuff out of mscorlib or creating a new, more core, assembly that just contains the bare minimum necessary types (e.g. System.Object, System.Int32, etc.) to make managed code work. This will give us the flexibility to add new innovations to the "optional" stuff, and make it easier to create different .NET Framework SKUs (e.g. the .NET Client Profile, Silverlight, etc.), without having to rev the runtime.

希望这会有所帮助!

谢谢, 贾斯汀

关于.net - mscorlib.dll 和 System.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/402582/

相关文章:

c# - 如何向 Html.ActionLink() url 添加描述性文本

.net - Linq to SQL 错误 SQL 不比较 NText、Text、Xml 或 Image?

resharper - 当我引用 System.Drawing 时,为什么 R# 会告诉我 "Cannot resolve assembly System.Drawing"?

c# - 合并到单个程序集时获取库版本

.net - .csproj的特定于平台的ItemGroup可用于程序集引用,但内容不包括?

c# - 提高此 Azure 表行计数查询的性能

c# - 在 Windows 机器上有没有办法以编程方式找出哪个应用程序负责打开具有特定扩展名的文件?

c# - 什么是 [assembly : InternalsVisibleTo ("MyAssembly")]? A statement, directive, ...?

visual-studio-2010 - 在项目模板中使用本地 IWizard 程序集作为 WizardExtension

c# - 指定自定义序列化程序时未反序列化故障详细信息