May 27th, 2010, 07:07 AM
Calling CoCreateInstance in C# (C++ to C# migration)
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
//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!
June 7th, 2010, 11:29 PM
Re: Calling CoCreateInstance in C# (C++ to C# migration)
Hi, I finally solved this problem:
Here is a link that helped me with how to use the Management Point API in C# : http://msdn.microsoft.com/en-us/library/cc144347.aspx and http://blogs.msdn.com/b/gabeb/archiv...et-part-1.aspx.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.