.NET 4.0 有一个新的 GAC,为什么?

标签 .net .net-4.0 gac

%windir%\Microsoft.NET\assembly\ 是新的 GAC 。这是否意味着现在我们必须管理两个 GAC,一个用于 .NET 2.0-3.5 应用程序,另一个用于 .NET 4.0 应用程序?

问题是,为什么?

最佳答案

是的,因为有 2 个不同的全局程序集缓存 (GAC),您必须单独管理它们。

In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR.

The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. There was no need in the previous two framework releases to split GAC. The problem of breaking older applications in Net Framework 4.0.

To avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

Source

为什么?

这似乎是因为 .NET 4.0 中发生了 CLR 更改,但 2.0 到 3.5 中没有更改。 1.1 到 2.0 CLR 也发生了同样的事情。看来 GAC 能够存储不同版本的程序集,只要它们来自同一个 CLR。他们不想破坏旧的应用程序。

请参阅 MSDN about the GAC changes in 4.0 中的以下信息.

For example, if both .NET 1.1 and .NET 2.0 shared the same GAC, then a .NET 1.1 application, loading an assembly from this shared GAC, could get .NET 2.0 assemblies, thereby breaking the .NET 1.1 application

The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. As a result of this, there was no need in the previous two framework releases to split the GAC. The problem of breaking older (in this case, .NET 2.0) applications resurfaces in Net Framework 4.0 at which point CLR 4.0 released. Hence, to avoid interference issues between CLR 2.0 and CLR 4.0, the GAC is now split into private GACs for each runtime.

随着 CLR 在未来版本中更新,您可以期待同样的事情。如果仅语言发生变化,那么您可以使用相同的 GAC。

关于.NET 4.0 有一个新的 GAC,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2660355/

相关文章:

asp.net - 如何捕获 ASP.NET 应用程序中未处理的异常?

.net - 在 32 位 Visual Studio 的同时在 64 位机器上进行调试

c# - 验证绑定(bind)到同一对象的不同属性的控件会重置对象值

multithreading - 我应该在库中使用.NET 4.0任务吗?

c# - 正则表达式匹配括号和大括号

visual-studio - 如何从 Visual Studio 引用 GAC 中的 dll?

c# - .NET Framework 类如何在不特定位数的情况下引用 native Windows DLL?

c# - 通过多行正则表达式匹配

.net - 数据库中立的 .NET 应用程序

.net - IIS/Sharepoint GAC 上的 DLL 缓存问题