【发布时间】:2011-02-17 16:58:14
【问题描述】:
我有一个c# 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。 我 regasm DLL,所以我有 tlb 文件。 然后我在 IDE 中导入了 tlb,它生成了一个 .h 和 .cpp 文件,就像它应该的那样。
long _MainClass::GiveInt2()
{
long result;
InvokeHelper(0x60020004, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
现在的问题是,当我调用该方法时,它只是 .. 不起作用,给我一个错误的输出(它在调用之前给出了 result 的值,就像 InvokeHelper 中有一个 try catch 一样)
为什么它不起作用? :(
非常感谢!
【问题讨论】:
-
从提供的信息中无法猜测。至少使用#import 指令。
标签: c# c++ dll visual-c++-6