开发者

C++ using C# DLL. Problem with InvokeHelper

I have a c# dll, really simple:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassTestPourCPP
{
    [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual开发者_StackOverflow中文版)]
    public class MainClass
    {
        public int GiveInt2()
        {
            return 2;
        }
    }
}

And I want my C++ app (VC6) to use it. So I built my dll with the option "set visible to com" enabled. I regasm the DLL, so I have the tlb file. Then I imported the tlb in the IDE, It generated a .h & .cpp file, exactly like it should.

long _MainClass::GiveInt2()
{
    long result;
    InvokeHelper(0x60020004, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
    return result;
}

The problem is now when I call the method, it just .. does not thing, giving me a wrong output (it gives the value of result before the call, like if there is a try catch inside the InvokeHelper)

Why isn't it working? :(

Thank you very much!


Did you call CoInitialize before trying to use the COM object?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜