Reputation: 41
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)]
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!
Upvotes: 0
Views: 1150
Reputation: 283733
Did you call CoInitialize
before trying to use the COM object?
Upvotes: 1