can't call COM method containing string

O

Owen Corpening

I have a C++ method and I want to call a C# method from it. passing in a
string. Works fine with int's, but if I have a string arg the method call is
skipped.
#import "../util/Release/AcornActuateUtil.tlb" raw_interfaces_only
using namespace AcornActuateUtil;
extern "C" UINT __stdcall InstallActuate (MSIHANDLE hInstall)
{
// Initialize COM.
HRESULT hr = CoInitialize(NULL);
// Get temporary folder name
long status = 0;
BSTR tempDirName;
status = getTempDir(hInstall, tempDirName);
if (status != ERROR_SUCCESS) return status;
// Create the interface pointer.
IConfigureActuateXmlPtr pIConfig(__uuidof(ConfigureActuateXml));
long lResult;
pIConfig->EditActuateConfigFile(tempDirName, &lResult);


The C#:

public interface IConfigureActuateXml
{
int EditActuateConfigFile(string s);
};
// Interface implementation.
public class ConfigureActuateXml:IConfigureActuateXml
{
private static readonly ILog log =
LogManager.GetLogger("ConfigureActuateXml");
public int EditActuateConfigFile(string s)
{

owen
 
D

Dan Bass

I'd use byte[] rather than string, then in the c# method perform a cast to
string, since C++ has no concept of string's as a basic type, but rather
char arrays.

Thanks.

Dan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top