I have called Matlab functions from C# using COM objects. It runs but on multiple calls it gives an exception while instantiating matlab Engine Interface through COM.
//for instantiating MATLAB Engine Interface through COM
MLApp.MLAppClass matlab = new MLApp.MLAppClass();
Exception it gives:
Unable to cast COM object of type 'MLApp.MLAppClass' to interface type 'MLApp.DIMLApp'. 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: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA).
I'm unable to figure this out. Any help will be appreciated.
I had the same problem. I was using 2 private functions, creating two different matlab objects inside that functions. Then I made the matlab object global problem solved(as below). But your problem might not be the same.
public partial class Form1 : Form
{
#region ----> Global Variables
// Create the MATLAB instance
MLApp.MLApp matlab = new MLApp.MLApp();
User contributions licensed under CC BY-SA 3.0