Calling COM wrapped c# dll from unmanaged c++: how to pass a 'string' and retrieve an updated value

StackOverflow https://stackoverflow.com/questions/3780069

Question

I use COM interop to call functions in a c# dll from my VC6 MFC DLL, and this works fine.
I want to call a function to retrieve string values.
How do I declare a 'string' in my unmanaged C++?
How should the 'string' appear in the c# code?
Currently the c# function in the dll takes ref string arguments, and my c# test app works fine, but what do I pass from an unmanaged c++ call?

Hope this makes sense. Any help welcome, Thanks.

No correct solution

OTHER TIPS

Problem solved.

I create a BSTR variable in my VC6 code:
BSTR key = SysAllocString(NULL);
I call my C# assembly:
presenter->GetObject(&key);
My C# function is:
void GetObject(ref string key);

:)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top