| | |
HELP~! how to call Matlab function in C#?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2006
Posts: 1
Reputation:
Solved Threads: 0
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~!
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
- Call to undefined function mysql_connect() (PHP)
- How to call a PHP function from Javascript and return the results back into Javascrip (PHP)
- matlab help : function, global, and ode45 (Legacy and Other Languages)
- Function call problem (HTML and CSS)
- using OCI to call a ORACLE stored function (C++)
Other Threads in the C# Forum
- Previous Thread: sort information in a listbox by name
- Next Thread: SQL Database loop
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development draganddrop drawing encryption enum event excel file filename finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile gis globalization gtk httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser windows winforms wpf xml





