Interface with C#, Visual Studio 2010 Express
5 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to send data to MATLAB through C# and am getting the " No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))." exception. Full code and error posted below.
I am using the examples that I found on this site: <http://www.mathworks.com/support/solutions/en/data/1-SJ9GS/?product=ML&solution=1-SJ9GS>
As shown, I add a reference (in my COM tab the only reference I find is "Matlab Application (Version 7.0) Type Library") and compile the project.
Basically upon running the code instantiates an MLAppClass object. This works fine, I see a Matlab Command window open up. But if I try to send data to the object, i.e. using even a basic ml.Execute("1+2"); or even ml.Quit(); and I get the error.
There was a post suggesting a registry key was wrong, but it didn't seem to help. I am running Matlab 7.0 and Visual Studio 2010.
Any suggestions? Thanks.
namespace cSharpCallsMATLAB
{
public class Form1 : System.Windows.Forms.Form
{
private MLApp.MLAppClass ml;
public Form1()
{
InitializeComponent();
ml = new MLApp.MLAppClass();
}
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void onButtonClick(object sender, System.EventArgs e)
{
resultBox.AppendText(ml.Execute("1+2") );
}
}
}
The exception is:
Unable to cast COM object of type 'System.__ComObject' to interface type 'MLApp.MLApp'.
This operation failed because the QueryInterface call on the COM component for the interface with IID '{669CEC93-6E22-11CF-A4D6-00A024583C19}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 5 月 25 日
You might have to (once) start up matlab from cmd and start it up with the /regserver flag, in order to register the automation server.
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler SDK についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!