944,137 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 7745
  • C# RSS
Dec 7th, 2006
0

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

Expand Post »
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~!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
christine21 is offline Offline
1 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: sort information in a listbox by name
Next Thread in C# Forum Timeline: SQL Database loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC