向 GAC 注册/安装程序集的“正确"方式是什么? [英] What's the 'correct' way of registering/installing an Assembly to the GAC?

查看:15
本文介绍了向 GAC 注册/安装程序集的“正确"方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有很多不同的方法可以向 GAC 注册程序集,因为它们有效".但是,这样做的正确"方式是什么?

回应 Lou Franco(和 gacutil):

我使用 Gacutil 进行开发,但在我看来这不是安装它的正确方法,因为 gacutil 不包含在 .NET 1.1 之后的基本 .NET 实用程序中 - 它只是一个开发人员工具.

附加:Gacutil(如下面的回复所示)不可再分发,因此不应在您打算提供给非开发人员的任何应用程序中使用.又名,客户.请参阅 Aaron Stebner 的这篇博文(和评论).

响应使用 WIX:

WIX 可能很棒,但它是如何工作的呢?哪些细节使 WIX 安装程序集的方式成为正确的安装方式?它怎么看?它是系统/.NET 调用吗?是否有需要在 System32 中某处埋藏的 dll 中进行调用?

(看起来 WIX 在幕后使用 MSI.在已接受的答案中查看我的评论.)

最终看起来将程序集安装到 GAC 的正确方法是使用 Windows 安装程序,仅此而已.我要试试 Wix.谢谢大家!

解决方案

使用 Wix 我会做这样的事情:

<前><DirectoryRef Id="MyDirectory" ><Component Id="MyComponent" Guid="PUT-GUID-HERE" DiskId="1"><File Id="MyAssembly" Name="MyAssembly.dll" Assembly=".net" KeyPath="yes" Source="MyAssembly.dll"/></组件></DirectoryRef>

当您在 WiX 中为文件使用属性 Assembly=".net" 时,它将在 MsiAssembly 和 MsiAssemblyName 表中为此组件创建条目并将其标记为 GAC 组件.

There seems to be lots of different ways to register assemblies with the GAC, as in, they 'work'. However, what's the "proper" way of doing it?

In response to Lou Franco (and gacutil):

I'm using Gacutil for development, but it seems to me to be not the proper way to install it, since gacutil isn't included in the basic .NET utilities past .NET 1.1 - it's only a developer tool.

Additional: Gacutil (as seen in responses below) is not redistributable, and therefore should not be used in any app that you intend to give to people who are not developers. AKA, customers. See This blog post (and comments) by Aaron Stebner.

In response to using WIX:

WIX might be great and all, but how does it work under the hood? What details makes the way WIX installs the assembly the right way to install it? How does it look it up? Is it a system/.NET call? Is there some call in a dll buried somewhere in System32 that needs to be made?

(Edit: it looks like WIX uses MSI under the hood. See my comments in the accepted answer.)

Final edit: It looks like the correct way to install an assembly to the GAC is using windows installer, and nothing else. I'm going to give Wix a try. Thanks all!

解决方案

With Wix I would do something like this:


<DirectoryRef Id="MyDirectory" >
    <Component Id="MyComponent" Guid="PUT-GUID-HERE" DiskId="1">
        <File Id="MyAssembly" Name="MyAssembly.dll" Assembly=".net" KeyPath="yes" Source="MyAssembly.dll" />
    </Component>
</DirectoryRef>

When you use the attribute Assembly=".net" for a file in WiX, it will create entries in the MsiAssembly and MsiAssemblyName table for this component and mark it as a GAC component.

这篇关于向 GAC 注册/安装程序集的“正确"方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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