Hi all,

I am migrating some code from C++ to a C# WebService, and specifically I use CoCreateInstance in the C++ code. I have two questions that interests me:

1) Is it possible to integrate a C++ code into the C# code?

2) If not, is there an equivalent CoCreateInstance in C#?

For more info, I import two files which are #include "SmsMsgAPI.h", #include "SmsMsgAPI_i.c". Then the CoCreateInstance looks like this:

sLocationRequest = sNewLocationRequest.AllocSysString();

sMPIPAddress = sMPIP.AllocSysString();



//Create root messaging object

_CHECKHR( ::CoCreateInstance(





(LPVOID*)&pMessaging) );

//Create message object for request

_CHECKHR( pMessaging->CreateMessage(&pRequest) );

//Set the target of the message to the Location Manager endpoint

_CHECKHR( pRequest->SetTargetEndpoint(L"MP_LocationManager") );

//Set the message body with the request

_CHECKHR( pRequest->SetBodyFromString(sLocationRequest) );

// Invoke the targeted endpoint on the local machine with the request,

// and retrieve the reply.

_CHECKHR( pMessaging->Invoke(sMPIPAddress, pRequest, &pReply) );

// Extract body from reply message.

_CHECKHR( pReply->GetBodyToString(&pszReplyMessage) );

wprintf(L"\n\nReply from MP:\n%s", (wchar_t *) pszReplyMessage);


Thank you in advance!