EDN Admin
Well-known member
I currently have something like this in my C# code that eventually results in a dll. My objective is to call a method in the client (a c++ console application) that uses a managed dll. For this purpose I am using delegates in my C# library. public delegate void TestDelegate(string par);
[ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("c9950e58-7c6e-4818-8fc9-adecbc7a6f14")]
public interface IOptionQuoter
{
void DelegTest(TestDelegate td);
}
[ComVisible(true), ClassInterface(ClassInterfaceType.None), Guid("fdb9e334-fae4-44f5-ab16-d874a910ec3c")]
public class OptionQuoterImp : IOptionQuoter
{
public void DelegTest(TestDelegate td)
{
td("SomeString");
}
}
Here is the C++ code that consumes the generated .tlb file of the dll. What should I pass in DelegTest() method so that it calls MyMethod(BSTR* bstrptr) ?void MyMethod(BSTR* bstrptr)
{
//I want this method to be called
}
int main()
{
HRESULT hr = CoInitialize(NULL);
Library::IOptionQuoterPtr pIQtr(__uuidof(OptionQuoterImp));
pIQtr->DelegTest() //What should be passed here it says that it requires IUnknown *td
A candle loses nothing by lighting another candle.
View the full article
[ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("c9950e58-7c6e-4818-8fc9-adecbc7a6f14")]
public interface IOptionQuoter
{
void DelegTest(TestDelegate td);
}
[ComVisible(true), ClassInterface(ClassInterfaceType.None), Guid("fdb9e334-fae4-44f5-ab16-d874a910ec3c")]
public class OptionQuoterImp : IOptionQuoter
{
public void DelegTest(TestDelegate td)
{
td("SomeString");
}
}
Here is the C++ code that consumes the generated .tlb file of the dll. What should I pass in DelegTest() method so that it calls MyMethod(BSTR* bstrptr) ?void MyMethod(BSTR* bstrptr)
{
//I want this method to be called
}
int main()
{
HRESULT hr = CoInitialize(NULL);
Library::IOptionQuoterPtr pIQtr(__uuidof(OptionQuoterImp));
pIQtr->DelegTest() //What should be passed here it says that it requires IUnknown *td
A candle loses nothing by lighting another candle.
View the full article