System.EnterpriseServices.Internal.Publish.GacInstall不工作,但没有任何错误
这里是我的代码:System.EnterpriseServices.Internal.Publish.GacInstall不工作,但没有任何错误
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.EnterpriseLibr ary.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 微软。 Practices.Unity.Interception.dll
他们是由别人给我的,所以我不确定你能在哪里得到他们,但肯定他们在网上提供。
该代码正确地输出该列表并且不会抛出任何异常,但运行gacutil /l
表明实际上只安装了其中的几个(下面突出显示)。
有什么可以去错了吗?
可能很重要:我的真正问题是,在我的InstallShield InstallScript安装程序中使用类似的代码(使用EnterpriseServices.Internal.Publish对象)不起作用。
此方法抛出也不例外! ...为了任何东西!
Publish pub = new Publish(); pub.GacInstall("foo");
没有错误,没有例外。如果路径有效,并且程序集名为 ,则它将正确安装在GAC中。适用于目标.NET Frame版本的 。即使用GacInstall的.NET Framework 4.0应用程序 将正确安装3.5目标程序集等。
更新(2011/12/13) - 使用ILSpy看看这个 函数的代码后,我发现,错误被发送到本地计算机的 事件查看器:
不幸的是,在事件查看器事件只说
安装在全局程序集缓存失败:富
它确实是Installshield。 EnterpriseLibrary程序集版本6的目标是.NET 4.0,因为Installshield只生成32位.exes,所以它调用了无法注册.NET 4.0 EnterpriseLibrary程序集的.NET 2.0 System.EnterpriseServices .dll。我添加了一个定制的C#工具来发布通过installscript调用的程序集。这是丑陋的,但它必须做,直到我们可以转换为WIX。