使用未记录的本机代码 API 将项目安装到 GAC 中

发布于 2024-08-05 01:27:52 字数 1105 浏览 3 评论 0原文

我正在开发一个项目,其设置使用 Microsoft 知识库文章 KB317540 中记录的 API 来在 GAC 中安装和卸载程序集。知识库文章指出:

总结
本机代码应用程序 编程接口 (API) 让您与全球互动 程序集缓存 (GAC) 不是 记录在 .NET Framework 中 软件开发套件 (SDK) 文档。

更多信息
注意:请勿使用 您的应用程序中的这些 API 执行程序集绑定或测试 集会或其他活动的存在 运行时、开发时或设计时 运营。仅管理工具 并且安装程序必须使用这些 蜜蜂。如果您使用 GAC,则此 直接将您的应用程序暴露给 装配结合脆弱性或可能 使您的应用程序正常工作 不正确地应用于未来版本 .NET框架。

GAC 存储的程序集是 在所有应用程序之间共享 电脑。实际存放位置 GAC 的结构并非 记录并可能会发生变化 .NET Framework 的未来版本 和 Microsoft Windows 操作系统 系统。

唯一支持的访问方法 GAC 中的大会是通过 本文档中记录的 API 文章。

大多数应用程序不必使用 这些 API 因为程序集 绑定自动执行 公共语言运行时。仅有的 自定义安装程序或管理 工具必须使用这些 API。微软 Windows Installer 具有本机支持 用于将程序集安装到 GAC。

有关程序集的更多信息 和 GAC,请参阅 .NET Framework SDK。

在以下情况下使用 GAC API 场景:当您安装 大会向 GAC 提交。当您删除时 GAC 大会。当你 从 GAC 导出程序集。什么时候 您枚举的程序集是 可在 GAC 中获取。笔记: CoInitialize(Ex) 必须先调用 您使用任何功能并且 本节中描述的接口 规格。

这种技术的优点和缺点是什么?这些 API 使用安全吗?有人在使用它们吗?如果是这样,为什么?

I'm working on a project whose setup uses the APIs documented in Microsoft Knowledge Base article KB317540 to install and uninstall assemblies into the GAC. The KB article states:

SUMMARY
The native code application
programming interfaces (APIs) that
allow you to interact with the Global
Assembly Cache (GAC) are not
documented in the .NET Framework
Software Development Kit (SDK)
documentation.

MORE INFORMATION
CAUTION: Do not use
these APIs in your application to
perform assembly binds or to test for
the presence of assemblies or other
run time, development, or design-time
operations. Only administrative tools
and setup programs must use these
APIs. If you use the GAC, this
directly exposes your application to
assembly binding fragility or may
cause your application to work
improperly on future versions of the
.NET Framework.

The GAC stores assemblies that are
shared across all applications on a
computer. The actual storage location
and structure of the GAC is not
documented and is subject to change in
future versions of the .NET Framework
and the Microsoft Windows operating
system.

The only supported method to access
assemblies in the GAC is through the
APIs that are documented in this
article.

Most applications do not have to use
these APIs because the assembly
binding is performed automatically by
the common language runtime. Only
custom setup programs or management
tools must use these APIs. Microsoft
Windows Installer has native support
for installing assemblies to the GAC.

For more information about assemblies
and the GAC, see the .NET Framework
SDK.

Use the GAC API in the following
scenarios: When you install an
assembly to the GAC. When you remove
an assembly from the GAC. When you
export an assembly from the GAC. When
you enumerate assemblies that are
available in the GAC. NOTE:
CoInitialize(Ex) must be called before
you use any of the functions and
interfaces that are described in this
specification.

What are the pros and cons of this technique? Are these APIs safe to use? Anyone out there using them? If so, why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北斗星光 2024-08-12 01:27:52

为什么不直接创建一个 Windows Installer 包呢?请参阅揭秘 .NET 全局程序集缓存。引用:

Windows Installer 的开发人员
包可以将程序集安装到
使用 Microsoft Windows 安装程序的 GAC
2.0。这是安装此类共享程序集的首选方式
应该是唯一的共享方式
组件安装在非
开发机器。

Why not just create a Windows Installer package? See Demystifying the .NET Global Assembly Cache. Quoting:

Developers of Windows Installer
packages can install assemblies to the
GAC using Microsoft Windows Installer
2.0. This is the preferred way for installing such shared assemblies and
should be the only way shared
assemblies are installed on non
development machines.

情话墙 2024-08-12 01:27:52

它说:“只有管理工具和安装程序必须使用这些 API。”

有一些工具(例如命令行工具)可与 GAC 配合使用。为什么不调用这些可执行文件,而不是直接使用这些 API?

It says, "Only administrative tools and setup programs must use these APIs."

There are tools (e.g. command-line tools) to work with the GAC. Why not invoke these executables, instead of using these APIs directly?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文