每次更改用户应用程序时,都需要将程序集重新部署到 GAC 中

发布于 2024-10-09 14:28:09 字数 606 浏览 0 评论 0原文


所以基本上我们有一个强名称(强签名)程序集 x.dll,它由我们的组件之一 App.exe 使用。程序集的签名密钥位于我们的存储库中,并且程序集通过写入的方式进行签名。

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFileAttribute(@"..\..\xxx.snk")]
[assembly: AssemblyKeyName("")]

程序集应该由安装通用软件包的某个安装程序放入 GAC 中,我们将其命名为 common.msi。但我们的组件本身是由App.msi安装的。当部署在一起时,一切正常。但是,当对 App.msi 进行更改(与 x.dll 完全无关)并且重新部署 App.msi 时,App.exe 无法找到 x.dll。请注意,未对 x.dll 进行任何更改。但是,当也部署 common.msi 时,一切正常。所以我猜测构建版本或其他东西一定存在问题,或者我一无所知的清单。有什么明显的事情表明我做错了吗?是否可以单独部署程序集,除非更改了程序集,否则不碰它,并且每次使用它的组件更改时都不必重新部署它?谢谢。

编辑:将程序集放入 GAC 是一项要求(我对此无能为力)



So basically we have an strong-names (strongly signed) assembly x.dll which is used by one of our components, App.exe. The signing key of the assembly is in our repository and it the assembly is signed by means of writing

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFileAttribute(@"..\..\xxx.snk")]
[assembly: AssemblyKeyName("")]

The assembly is supposed to be put in GAC by some installer which installs common packages, let's name it common.msi. But our component itself is installed by App.msi. When deployed together, everything works. But when changes are made to App.msi, ones that have ABSOLUTELY nothing to do with x.dll, and App.msi is redeployed, App.exe fails to find x.dll. Note that no changs are made to x.dll. When, however, common.msi is deployed as well, everything works. So I am guessing there must be an issue with build versions or something, or manifests which I know nothing about. Is there something obvious that I am doing wrong? Isn't it possible to just deploy the assembly separately and not touch it unless it is changed and not redeploy it every time a component that uses it is changed? Thanks.

Edit: It is a requirement (one I can't do anything about) that the ssembly be put in GAC

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

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

发布评论

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

评论(1

一指流沙 2024-10-16 14:28:09

为什么要把它安装到 GAC 中?不要那样做。

您的问题标题“需要将程序集重新部署到 GAC 中”是错误的。
您所写的任何内容都没有暗示程序集需要位于 GAC 中。


编辑 - 一些附加信息。

如果您想检查依赖关系,您可以使用 Redgate 的 Reflector 来检查程序集(例如 App.exe),以确定它依赖和需要哪些其他程序集。这些依赖项将包括版本号。

我不知道命令行中的工具只会发出程序集信息。也许有一个。由于缺乏这一点,我编写了一个工具来完成此操作,如下所示:

    public static void Main(string[] args)
    {
        if ((((args == null) || (args.Length != 1)) || (args[0] == "-?")) || (args[0] == "-h"))
        {
            Usage();
        }
        else
        {
            try
            {
                Console.WriteLine(Assembly.LoadFrom(args[0]).FullName.ToString());
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception: {0}", exception.ToString());
                Usage();
            }
        }
    }

您可以在 App.exe 和 x.dll 上运行此工具,以确定嵌入到每个程序集中的确切强名称,包括版本号。

这可能有助于您深入了解为什么事情没有按您的预期进行。

即使 x.dll 的一个版本位于 GAC 中,也不需要任意应用程序(例如 App.exe)使用该版本的 DLL。应用程序可以在本地目录中安装其自己版本的 dll。

Why are you installing it into the GAC? Don't do that.

The title of your question "Assembly needs to be redeployed into GAC" is just wrong.
Nothing you've written implies that the assembly needs to be in the GAC.


EDIT - some additional information.

If you want to examine dependencies, you can use Redgate's Reflector to examine an assembly, like your App.exe, to determine which other assemblies it depends on and requires. These dependencies will include version numbers.

I don't know of a tool from the commandline that will just emit assembly information. Maybe there is one. Lacking this, I wrote a tool to do it, like this:

    public static void Main(string[] args)
    {
        if ((((args == null) || (args.Length != 1)) || (args[0] == "-?")) || (args[0] == "-h"))
        {
            Usage();
        }
        else
        {
            try
            {
                Console.WriteLine(Assembly.LoadFrom(args[0]).FullName.ToString());
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception: {0}", exception.ToString());
                Usage();
            }
        }
    }

You could run this tool on App.exe as well as x.dll to determine the exact strong name, including version numbers, embedded into each assembly.

This might help give you some insight into why things aren't working as you expect.

Even if one version of x.dll is in the GAC, there's no need for an arbitrary app, like App.exe, to use that version of the DLL. The app can install in the local directory its own version of the dll.

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