【问题标题】:System.EnterpriseServices.Internal.Publish.GacInstall not working but no errorsSystem.EnterpriseServices.Internal.Publish.GacInstall 不工作但没有错误
【发布时间】:2016-03-06 20:01:45
【问题描述】:

这是我的代码:

var s = new System.EnterpriseServices.Internal.Publish();
foreach (string file in Directory.EnumerateFiles(@"C:\Program Files\MyFolder\MSPractices"))
{
    Console.WriteLine("GACing " + file);
    s.GacInstall(file);
}

这些是我正在尝试 GAC 的文件(版本 6.0.1304.0)

Microsoft.Practices.EnterpriseLibrary.Caching.dll Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Data.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll Microsoft.Practices.EnterpriseLibrary.Logging.dll Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll Microsoft.Practices.EnterpriseLibrary.Security.dll Microsoft.Practices.EnterpriseLibrary.Validation.dll Microsoft.Practices.ServiceLocation.dll Microsoft.Practices.Unity.Configuration.dll Microsoft.Practices.Unity.dll Microsoft.Practices.Unity.Interception.Configuration.dll Microsoft.Practices.Unity.Interception.dll

它们是别人给我的,所以我不确定你在哪里可以得到它们,但肯定可以在线获得。

代码正确输出了该列表并且没有抛出任何异常,但运行 gacutil /l 显示只有少数几个(在下面突出显示)实际安装。

可能出了什么问题?

可能很重要:我真正的问题是,这在我的具有类似代码的 InstallShield InstallScript 安装程序中不起作用(使用 EnterpriseServices.Internal.Publish 对象)。

UPDATE:

这个方法不会抛出异常! ...为了任何东西! Publish pub = new Publish(); pub.GacInstall("foo");

没有错误,没有例外。如果路径有效,并且程序集是 强命名,它将正确安装在 GAC 中。效劳于 目标 .NET Frame 版本的程序集。 IE。 .NET Framework 4.0 应用 使用 GacInstall 将正确安装 3.5 目标程序集等。

更新 (2011/12/13) - 使用 ILSpy 查看代码后 功能,我确实发现错误被发送到本地机器的 事件查看器:

不幸的是,事件查看器中的所有事件都只说

在全局程序集缓存中安装失败:foo

【问题讨论】:

    标签: c# installshield gac installscript


    【解决方案1】:

    您已经得出结论,这些方法并不总是有用的。

    如果您想要一个更强大的方法,您可以使用 C# 中的 GAC/Fusion API 记录 herehere。可以在 here(感谢 Hans Passant)、herehere 中找到 C# 中的示例。

    您也可以尝试 gacutil.exe 来查看问题所在。您可以在安装了 Visual Studio 的机器上找到它。

    【讨论】:

      【解决方案2】:

      它确实是Installshield。 EnterpriseLibrary 程序集的第 6 版面向 .NET 4.0,并且由于 Installshield 仅构建 32 位 .exe,它正在调用无法注册 .NET 4.0 EnterpriseLibrary 程序集的 .NET 2.0 System.EnterpriseServices .dll。我添加了一个自定义 C# 工具来发布通过 installscript 调用的程序集。这很丑陋,但在我们可以转换为 WIX 之前它必须这样做。

      【讨论】:

        【解决方案3】:

        我今天遇到了类似的问题;机器已重新启动。 我在非管理员模式下打开了 Powershell ISE,运行了我已经运行了 100 秒的相同脚本,它的行为就像它运行但它没有运行一样。问题是以管理员身份打开。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-11-10
          • 2019-12-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-10-02
          • 2014-12-10
          相关资源
          最近更新 更多