2014-02-05 22 views
0

合作伙伴在C#中用.NET框架4創建了一個COM lib x.dll和x.tlb。他有「Com Interop 「複選框在VS中檢查。.NET Interop'Method not found:'Void System.Threading.Monitor.Enter ..

然後他提到這個Register a C#/VB.NET COM dll programmatically創建一個註冊.dll的工具。有效。 (我們的Delphi應用程序可以訪問.COM對象),他用來註冊的代碼(從上面的鏈接)是:

Assembly asm = Assembly.LoadFile (@"c:\temp\x.dll"); 
RegistrationServices regAsm = new RegistrationServices(); 
bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase); 

我們進口x.tlb到德爾福7,創建一個.PAS文件,通過它我們正在調用COM庫。

在Delphi中,當我們在COM庫中調用一個函數,我們得到了一個錯誤:

...exception class EOleException with message 'Method not found: 'Void 
System.Threading.Monitor.Enter(System.Object, Boolean ByRef)''. Process stopped. 

我們不知道這意味着什麼或如何解決它。

有什麼建議嗎?

+1

不知何故,它使用以前版本的.NET。有沒有設置目標平臺的地方? –

+0

@LURD在編譯時,當您創建C#.dll時,您可以指定預期的.NET版本。 –

+0

@ArnaudBouchez,是的,這就是我的意思。 –

回答

0

當編譯C#DLL,它是框架4.

確保在編譯器中設定的目標是正確的平臺版本之前的一個針對.NET版本。

相關問題