Hello, I've cretaed a Matlab function and managed to call it out in C++. But, when i convert my C++ to C#, there's an 'AccessViolationException Unhandled' error.
Besides, i have successfully import the mclmcr.dll and my function dll in C# by using [DllImport(@"mclmcr70.dll")] method.
Below is my C++ codes:
[mxArray *imageName = NULL;
imageName = mxCreateString("demo1.jpg");
// Call the function
mlfVaanalysis(imageName, outputName);
mxDestroyArray(imageName); imageName=NULL;]
After converted to C#:
[IntPtr imgName= VamDLL.mxCreateString("demo1.jpg");
VamDLL.mlfVaanalysis(imgName,outputName);
VamDLL.mxDestroyArray(imgName);]
where the VamDLL is the C# class i use [DllImport(@"mclmcr70.dll")] to call the following method
[DllImport(@"mclmcrrt70.dll")]
public static extern void mxDestroyArray([In] IntPtr mxArray);
[DllImport(@"mclmcrrt70.dll")]
public static extern IntPtr mxCreateString(string str);
[DllImport(@"vam.dll")]
public static extern bool mlfVaanalysis([In] IntPtr imgName, [In] IntPtr outputName);
the violation error occured at the line IntPtr imgName= VamDLL.mxCreateString("demo1.jpg");
Anybody know what's the correct way to call mxCreateString in C#?
How should i call the function?
thanks for your help~!