gpt4 book ai didi

c# - System.EnterpriseServices.Internal.Publish.GacInstall 不工作但没有错误

转载 作者:太空狗 更新时间:2023-10-30 01:16:47 24 4
gpt4 key购买 nike

这是我的代码:

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 显示实际上只安装了其中的几个(下面突出显示)。

enter image description here

可能出了什么问题?

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

UPDATE :

This method throws no exception! ...for anything! Publish pub = new Publish(); pub.GacInstall("foo");

No error, no exception. If the path is valid, and the assembly is strongly named, it will get properly installed in the GAC. Works for target .NET Frame version of assembly. I.e. a .NET Framework 4.0 app using GacInstall will properly install a 3.5 targeted assembly, etc.

Update (2011/12/13) - After using ILSpy to look at the code for this function, I did discover that errors are sent to the local machine's Event Viewer:

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

Installation in the global assembly cache failed: foo

最佳答案

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

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

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

关于c# - System.EnterpriseServices.Internal.Publish.GacInstall 不工作但没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34045117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com