這裏是我的代碼: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看看這個 函數的代碼後,我發現,錯誤被髮送到本地計算機的 事件查看器:
不幸的是,在事件查看器事件只說
安裝在全局程序集緩存失敗:富