0
  • 我想添加一個dll到報表瀏覽器,這樣我可以利用該方法進行解碼的字段內容(在報告中)的一個該DLL。
  • 我在Report Properties - > References中添加了一個dll。
  • 類庫中的所有方法(用於創建dll)都是靜態的。
  • 在於類庫類的內容:ABCClass.cs(用於創建該dll ABCCollection.dll)報表查看器(Visual Studio中)錯誤:使用自定義組件與RDLC報告

    namespace ABCCollection 
        { 
         public class ABCClass 
         { 
          public static string CustomFormatString(string s) 
          { 
           //perform some operation on s 
           return s; 
          } 
         } 
        } 
    

在Report1.rdlc,我使用的值的字段如:

=ABCCollection.ABCClass.CustomFormatString("testing") 

但是,一旦我運行這個報告,我得到的錯誤是:

Error while loading code module: ‘ABCCollection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Details: Could not load file or assembly 'ABCCollection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. 

有人可以幫我嗎?

回答

0

編譯DLL時檢查項目屬性給出的命名空間,通常它將是項目的名稱。在這種情況下,您實際上是兩次定義名稱空間。所以叫它從DLL創建它將會是:

ABCCollection.ABCCollection.ABCClass.CustomFormatString(「測試」)

0

做到這一點的唯一方法是通過添加組件安裝到GAC。 有一個很好的例子here

最終,這一切都下到這一點:

  1. 使用Visual Studio項目屬性窗口中創建一個單獨的項目ABCCollection.dll
  2. 簽署,引起別人你想成爲能夠將其添加到gac。
  3. GACUTIL - 如果 「路徑ABCCollection.dll」
  4. 不要忘了加上 「[裝配:AllowPartiallyTrustedCallers()]」 你ABCCollection/AssemblyInfo.cs文件,否則你希望能夠調用這些函數。

你就完成了!

相關問題