[英]C++ using C# DLL. Problem with InvokeHelper
我有一個ac#dll,真的很簡單:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassTestPourCPP
{
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)]
public class MainClass
{
public int GiveInt2()
{
return 2;
}
}
}
我希望我的C ++應用程序(VC6)使用它。 因此,我在啟用“設置對com可見”的選項的情況下構建了自己的dll。 我給DLL加氣,所以有了tlb文件。 然后我將tlb導入到IDE中,它生成了一個.h&.cpp文件,完全應該如此。
long _MainClass::GiveInt2()
{
long result;
InvokeHelper(0x60020004, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
現在的問題是,當我調用該方法時,它只是..沒什么,給我一個錯誤的輸出(它在調用之前給出了結果的值,就像InvokeHelper中是否有try catch一樣)
為什么不起作用? :(
非常感謝你!
在嘗試使用COM對象之前,您是否致電CoInitialize
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.