HELP~! how to call Matlab function in C#?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2006
Posts: 1
Reputation: christine21 is an unknown quantity at this point 
Solved Threads: 0
christine21 christine21 is offline Offline
Newbie Poster

HELP~! how to call Matlab function in C#?

 
0
  #1
Dec 7th, 2006
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~!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC