何时以及何时不安装到 GAC 中? [英] When and when-not to install into the GAC?

查看:19
本文介绍了何时以及何时不安装到 GAC 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候应该安装到 GAC 中,什么时候不应该?(实际上,我指的是在客户购买我们的产品后安装在他们的机器上).

When should you install into the GAC and when should you not? (I am referring, really, to installing on a client's machine when they have purchased our product(s)).

  1. 我有一个程序集,它只能用于我的一个应用程序(GAC 或非 GAC)?

  1. I have an assembly that is only going to be used with my one application (GAC or no-GAC)?

我的所有应用程序都共享一个程序集(GAC 或非 GAC)?

I have an assembly that all my applications share (GAC or no-GAC)?

我的所有应用程序可能使用我的程序集的不同版本(GAC 还是非 GAC)?

All my applications may use different versions of my assembly (GAC or no-GAC)?

这是三种情况……但我相信还有更多情况.我不一定只寻找这三个问题的答案.

These are three scenarios... but I am sure there are more. I'm not necessarily looking an answer to only these three questions.

类似问题:什么使用 GAC 的优点和缺点是什么?

推荐答案

一般 MS 指南

GAC 实际上是 Microsoft 常用 .NET 库的存储库.是的,他们也让开发人员使用它,但根据经验,如果您不需要 GAC,请不要使用它.如果没有伤害,请保持简单和本地化.

GAC is really a repository for Microsoft common .NET libraries. Yes, they let developers use it too, but as a rule of thumb, if you don't need GAC, don't use it. keep things simple and local if it doesn't hurt.

  • 我只会出于性能原因考虑 GAC,例如,如果您有一些大型程序集,请尝试将它们放入 GAC 和 NGEN 他们.它应该显着提高性能.Microsoft 在安装期间为所有标准 .NET 框架程序集执行此操作(现在您知道为什么安装需要这么长时间了).Paint.NET 也这样做(以改善其应用程序的启动时间).然而,我们中的大多数人都不在大型框架或 photoshop 竞争对手上工作,所以大多数时候,在 GAC 中组装的性能提升是微乎其微的.不值得放弃简单的 x-copy 部署.

  • I would consider GAC only for performance reasons, for example if you have some huge assemblies, try to place them into GAC and NGEN them. It should significantly increase performance. Microsoft does it for all standard .NET framework assemblies during installation (now you know why that installation takes so long). Paint.NET does it as well (to improve startup time of their app). However most of us don't work on huge frameworks or photoshop competitors, so most of the time, performance gains from having assembly in GAC are minimal. Not worth giving up simple x-copy deployment.

某些开发人员可能会使用 GAC 来确保权限不足的用户无法删除或修改其程序集.

Some developers might use GAC to make sure that users with insufficient privileges can't delete or modify their assemblies.

对于其他人来说,这可能是出于版本控制的原因,但在这里您真的应该重新考虑一下.我不会重复已经说过的内容,您可以在这里阅读原因.

For others it might be for versioning reasons but here you should really reconsider. I'm not going to repeat what has been already said, you can read here why.

并且不要忘记,一旦您想部署到 GAC 中,您的安装程序将需要管理员权限,您几乎可以忘记单击一次部署等...

And don't forget that once you want to deploy into GAC, your installer will need administrator privileges, you can pretty much forget click-once deployment, etc...

这篇关于何时以及何时不安装到 GAC 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆