2012-08-05 89 views
1

我使用了教程(http://support.microsoft.com/kb/837908,方法1)來生成兩個項目。項目a對項目b有參考價值。在運行時加載程序集

項目:

new System.EnterpriseServices.Internal.Publish().GacRemove(string.Format(@"C:\Users\[me]\Documents\Visual Studio 2010\Projects\MyAssembly1\MyAssembly1\bin\Debug\MyAssembly1.dll")); 
new System.EnterpriseServices.Internal.Publish().GacInstall(string.Format(@"C:\Users\[me]\Documents\Visual Studio 2010\Projects\MyAssembly1\MyAssembly1\bin\Debug\MyAssembly1.dll")); 
MyAssembly1.Class1 obj1 = new MyAssembly1.Class1(); 
MessageBox.Show(obj1.HelloWorld()); 

項目B:

public string HelloWorld() 
    { 
     return "1"; 
    } 

當我執行以下操作:在項目

  1. 變 「HelloWorld」 的方法B來返回「2」(而不是o f「1」)。

  2. 建設項目B

  3. 建設項目,並運行它

我與「1」作爲文本消息框,和GAC並不總是自動更新。

更新項目b並在項目a上查看它的最簡單方法是什麼?

+0

這似乎是錯誤的。您不應該在同一過程中安裝到GAC。 – leppie 2012-08-05 14:37:44

+0

GacRemove()採用文件系統路徑的奇怪之處。它應該有一個名稱,包括版本。那麼,這是一種失敗模式。 – 2012-08-05 15:15:21

回答

0

首先,更改GAC不太可能有助於已經運行的進程。在此特定情況下,請注意,在執行該方法之前,每個方法都會發生JIT 之前的。這意味着MyAssembly1在刪除/安裝步驟之前已解析並加載。然而,這並不能改變這一事實,這不太可能是一個好方法。

相關問題