MWArray and C#: Returned Handle to Matlab figure is null in C#-Code

1 view (last 30 days)
Hello,
we have an .NET application that calls Matlab-Function. We are using the MWArray.dll for the interaction between .NET and Matlab. We call the Matlab-Function with MWMCR.EvaluateFunction(). This matlab-function opens a plot/figure and returns the handle to this plot/figure. If we call this function from .NET the returned handle is always NULL. If we test this function in Matlab everything is fine. The handle is not null. It seems like the handle is getting lost between Matlab and .NET.
Thnx for your help!

Answers (1)

Rohit Kudva
Rohit Kudva on 21 Oct 2015
Hi Christian,
I understand that you have compiled a MATLAB function (that opens a plot/figure and returns the handle to this plot/figure) to a .NET DLL that you have integrated with your .NET application. The function executes fine in MATLAB but returns NULL while called from .NET application.
There are certain data conversion rules used when converting MATLAB data type to native .NET types. You can look into the conversion table in this link. According to this conversion table, there is no native type in .NET for handles in MATLAB and thus the call to the MATLAB function from .NET application returns NULL.
Regards,
Rohit

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!