5

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 exception 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!

1 Answer 1

3

First of all, take a look here:

If it don't help, try to Enable Unsafe Mode, it may solve some problems with com objects.

Sign up to request clarification or add additional context in comments.

5 Comments

I had followed the form that one of the examples I found used, and the strange thing is that the exact same program works on one system (it launches the Matlab command window and executes instructions) but gives me the 80080005 error on the other. Could you think of any possible reasons C# could have trouble contacting Matlab on one computer and not another?
FYI, the simple program I'm testing with is the following:
namespace WindowsFormsApplication1 { public partial class Form1 : Form { private MLApp.MLAppClass ml; public Form1() { InitializeComponent(); ml = new MLApp.MLAppClass(); } private void button1_Click(object sender, EventArgs e) { ml.Execute("imagesc(double(rand(50)))"); } } }
I had some problem with code who work properly on Vista 64 and throw an exception on XP 32... This code was executing some batch command line in an hidden console. I never found why, I just show the console, and it work. It work also if I enable unsafe mode strangely...
What are the specs of your 2 config (OS, 32/64, .Net version...) ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.