热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

.NET4.0有了一个新的GAC,为什么?-.NET4.0hasanewGAC,why?

%windir%\Microsoft.NET\assembly\isthenewGAC.DoesitmeannowwehavetomanagetwoGACs,onefo

%windir%\Microsoft.NET\assembly\ is the new GAC. Does it mean now we have to manage two GACs, one for .NET 2.0-3.5 applications and the other for .NET 4.0 applications?

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

The question is, why?

问题是,为什么?

3 个解决方案

#1


177  

Yes since there are 2 distinct Global Assembly Cache (GAC), you will have to manage each of them individually.

是的,因为有两个不同的全局程序集缓存(GAC),所以您必须分别管理它们。

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

在。net Framework 4.0中,GAC经历了一些变化。GAC被分成两部分,每一部分对应一个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.

用于。net Framework 2.0和。net Framework 3.5的CLR版本是CLR 2.0。在之前的两个框架版本中不需要拆分GAC。在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.

为了避免CLR 2.0和CLR 4.0之间的问题,GAC现在在每个运行时都被分为私有的GAC。主要的变化是CLR v2.0应用程序现在不能在GAC中看到CLR v4.0程序集。

Source

Why?

为什么?

It seems to be because there was a CLR change in .NET 4.0 but not in 2.0 to 3.5. The same thing happened with 1.1 to 2.0 CLR. It seems that the GAC has the ability to store different versions of assemblies as long as they are from the same CLR. They do not want to break old applications.

这似乎是因为。net 4.0中有CLR的变化,而不是2.0到3.5。同样的事情也发生在1.1到2.0的CLR上。GAC似乎可以存储不同版本的程序集,只要它们来自同一个CLR。他们不想破坏旧的应用程序。

See the following information in MSDN about the GAC changes in 4.0.

关于4.0中GAC的变化,请参阅MSDN中的以下信息。

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

例如,如果.NET 1.1和.NET 2.0共享相同的GAC,那么.NET 1.1应用程序从这个共享的GAC加载程序集,就可以得到.NET 2.0程序集,从而破坏。net 1.1应用程序

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.

用于。net Framework 2.0和。net Framework 3.5的CLR版本是CLR 2.0。因此,在前两个框架版本中不需要拆分GAC。打破旧的(在本例中是。Net 2.0)应用程序的问题在netframework 4.0中重新出现,CLR 4.0在那时发布。因此,为了避免CLR 2.0和CLR 4.0之间的干扰问题,GAC现在被分割为每个运行时的私有GACs。

As the CLR is updated in future versions you can expect the same thing. If only the language changes then you can use the same GAC.

由于CLR在将来的版本中被更新,您可以期待同样的事情。如果语言改变了,那么您可以使用相同的GAC。

#2


66  

I also wanted to know why 2 GAC and found the following explanation by Mark Miller in the comments section of .NET 4.0 has 2 Global Assembly Cache (GAC):

我也想知道为什么2 GAC,在。net 4.0的评论部分,Mark Miller给出了如下解释:

Mark Miller said... June 28, 2010 12:13 PM

马克米勒说……2010年6月28日下午12:13

Thanks for the post. "Interference issues" was intentionally vague. At the time of writing, the issues were still being investigated, but it was clear there were several broken scenarios.

谢谢你的帖子。“干涉问题”故意含糊其辞。在撰写本文时,这些问题仍在调查中,但很明显,有好几种情况已经被打破。

For instance, some applications use Assemby.LoadWithPartialName to load the highest version of an assembly. If the highest version was compiled with v4, then a v2 (3.0 or 3.5) app could not load it, and the app would crash, even if there were a version that would have worked. Originally, we partitioned the GAC under it's original location, but that caused some problems with windows upgrade scenarios. Both of these involved code that had already shipped, so we moved our (version-partitioned GAC to another place.

例如,一些应用程序使用Assemby。LoadWithPartialName加载程序集的最高版本。如果最高版本是用v4编译的,那么v2(3.0或3.5)应用程序就无法加载它,即使有一个版本可以运行,应用程序也会崩溃。最初,我们在它的原始位置对GAC进行分区,但是这在windows升级场景中造成了一些问题。这两个都涉及到已经发布的代码,因此我们将(版本分区的GAC)移动到另一个位置。

This shouldn't have any impact to most applications, and doesn't add any maintenance burden. Both locations should only be accessed or modified using the native GAC APIs, which deal with the partitioning as expected. The places where this does surface are through APIs that expose the paths of the GAC such as GetCachePath, or examining the path of mscorlib loaded into managed code.

这应该不会对大多数应用程序产生任何影响,也不会增加任何维护负担。应该只使用本地GAC api访问或修改这两个位置,这些api按照预期处理分区。这些地方是通过api来显示GAC的路径的,比如GetCachePath,或者检查加载到托管代码中的mscorlib路径。

It's worth noting that we modified GAC locations when we released v2 as well when we introduced architecture as part of the assembly identity. Those added GAC_MSIL, GAC_32, and GAC_64, although all still under %windir%\assembly. Unfortunately, that wasn't an option for this release.

值得注意的是,我们在发布v2时修改了GAC位置,当我们将体系结构作为程序集标识的一部分引入时也是如此。它们添加了GAC_MSIL、GAC_32和GAC_64,尽管它们仍然在%windir%\程序集之下。不幸的是,这个版本没有这个选项。

Hope it helps future readers.

希望它能帮助未来的读者。

#3


63  

It doesn't make a lot of sense, the original GAC was already quite capable of storing different versions of assemblies. And there's little reason to assume a program will ever accidentally reference the wrong assembly, all the .NET 4 assemblies got the [AssemblyVersion] bumped up to 4.0.0.0. The new in-process side-by-side feature should not change this.

这没有多大意义,最初的GAC已经能够存储不同版本的程序集。并且没有理由假设一个程序会偶然地引用错误的程序集,所有。net 4程序集的[汇编版本]都增加到4.0.0.0。新的并行进程特性不应该改变这一点。

My guess: there were already too many .NET projects out there that broke the "never reference anything in the GAC directly" rule. I've seen it done on this site several times.

我的猜测是:已经有太多的。net项目打破了“绝对不要直接引用GAC中的任何东西”的规则。我在这个网站上见过好几次。

Only one way to avoid breaking those projects: move the GAC. Back-compat is sacred at Microsoft.

只有一种方法可以避免破坏这些项目:移动GAC。反编译在微软是神圣的。


推荐阅读
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • SpringMVC接收请求参数的方式总结
    本文总结了在SpringMVC开发中处理控制器参数的各种方式,包括处理使用@RequestParam注解的参数、MultipartFile类型参数和Simple类型参数的RequestParamMethodArgumentResolver,处理@RequestBody注解的参数的RequestResponseBodyMethodProcessor,以及PathVariableMapMethodArgumentResol等子类。 ... [详细]
  • Android自定义控件绘图篇之Paint函数大汇总
    本文介绍了Android自定义控件绘图篇中的Paint函数大汇总,包括重置画笔、设置颜色、设置透明度、设置样式、设置宽度、设置抗锯齿等功能。通过学习这些函数,可以更好地掌握Paint的用法。 ... [详细]
  • 本文介绍了使用Spark实现低配版高斯朴素贝叶斯模型的原因和原理。随着数据量的增大,单机上运行高斯朴素贝叶斯模型会变得很慢,因此考虑使用Spark来加速运行。然而,Spark的MLlib并没有实现高斯朴素贝叶斯模型,因此需要自己动手实现。文章还介绍了朴素贝叶斯的原理和公式,并对具有多个特征和类别的模型进行了讨论。最后,作者总结了实现低配版高斯朴素贝叶斯模型的步骤。 ... [详细]
author-avatar
you是was的was
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有