Calling Matlab from C# using COM object
I'm trying to make a simple C# GUI that uses Matlab for its processing. I'm trying to use the Matlab application COM object for communication but am getting the following error during allocation:
An unhandled exceptio开发者_如何转开发n of type 'System.Runtime.InteropServices.COMException' occurred in cSharpCallsMATLAB.exe
Additional information: Retrieving the COM class factory for component with CLSID {491B6189-7E9D-43F4-A7DE-C062DF7B326E} failed due to the following error: 80080005.
Earlier I create the necessary object:
private MLApp.MLAppClass ml;
and assign it in the form constructor:
ml = new MLApp.MLAppClass();
and the program hangs on that line and returns an error after about 5 seconds.
I've looked around but can't seem to fix this problem. Does anyone have any advice on how to get C# to successfully connect to Matlab?
Thanks!
First of all, take a look here:
- Best way to access COM objects from C#
- Integrating MATLAB with C#
- 1..2..3 ways of integrating MATLAB with the .NET
If it don't help, try to Enable Unsafe Mode, it may solve some problems with com objects.
精彩评论