82

mscorlib 绝对是 .net 基类库之一,C# 中的每个程序都依赖于它,但它代表什么?

C# 语言规范的 ECMA 标准中,这个词被提到了 4 次,但没有一个是指它的含义。

4

3 回答 3

83

Micro s oft C ommon Object R untime。_ _

请参阅http://www.danielmoth.com/Blog/mscorlibdll.aspx“Cor”代表什么?

于 2013-02-25T07:30:13.990 回答
42

Microsoft Core Library,即它们是一切的核心。

您可能更喜欢“按摩”的解释:

“当微软刚开始开发 .NET Framework 时,MSCorLib.dll 是 Microsoft Common Object Runtime Library 的首字母缩写词。一旦 ECMA 开始标准化 CLR 和 FCL 的部分内容,MSCorLib.dll 正式成为 Multilanguage Standard Common Object 的首字母缩写词运行时库。”

来自http://weblogs.asp.net/mreynolds/archive/2004/01/31/65551.aspx

1999 年左右,在我个人的记忆中,.Net 被称为“COOL”,所以我对这个派生有点怀疑。我从来没有听说过它叫做“COR”,对于一个以英语为母语的人来说,这是一个听起来很傻的名字。

于 2013-02-25T07:26:49.077 回答
36

它代表

Microsoft 的通用对象运行时库

它是框架公共库的主要程序集。

它包含以下命名空间:

 System
 System.Collections
 System.Configuration.Assemblies
 System.Diagnostics
 System.Diagnostics.SymbolStore
 System.Globalization
 System.IO
 System.IO.IsolatedStorage
 System.Reflection
 System.Reflection.Emit
 System.Resources
 System.Runtime.CompilerServices
 System.Runtime.InteropServices
 System.Runtime.InteropServices.Expando
 System.Runtime.Remoting
 System.Runtime.Remoting.Activation
 System.Runtime.Remoting.Channels
 System.Runtime.Remoting.Contexts
 System.Runtime.Remoting.Lifetime
 System.Runtime.Remoting.Messaging
 System.Runtime.Remoting.Metadata
 System.Runtime.Remoting.Metadata.W3cXsd2001
 System.Runtime.Remoting.Proxies
 System.Runtime.Remoting.Services
 System.Runtime.Serialization
 System.Runtime.Serialization.Formatters
 System.Runtime.Serialization.Formatters.Binary
 System.Security
 System.Security.Cryptography
 System.Security.Cryptography.X509Certificates
 System.Security.Permissions
 System.Security.Policy
 System.Security.Principal
 System.Text
 System.Threading
 Microsoft.Win32 

有关 MSCorlib 的有趣信息:

  • .NET 2.0 程序集将引用并使用 2.0 mscorlib。 .NET 1.1程序集将引用1.1 mscorlib但将在运行时使用 2.0 mscorlib(由于运行时本身的硬编​​码版本重定向)
  • 在 GAC 中只有一个版本的 mscorlib,即使您的机器上安装了 1.1 框架,您也不会在 GAC 上找到 1.1 版本。如果有人能解释为什么MSCorlib 2.0 单独在 GAC 中而 1.x 版本位于框架文件夹中,那就太好了
  • 是否可以通过在 app/web.config 中进行配置设置来强制应用程序加载不同的运行时?您将无法通过 ConfigurationFile 中的设置来选择 CLR 版本——此时,一个 CLR 已经在运行,并且每个进程只能有一个。选择 CLR 后,将立即加载适合该 CLR 的 MSCorlib。
于 2013-02-25T07:39:37.527 回答