MATLAB: Am I getting the error “The type or namespace ‘MLApp’ could not be found” when building C# application using MATLAB

codegenerationMATLAB Compiler SDK

I am trying to connect to the MATLAB Application COM interface from my C# project and when I try to build it I get the error "The type or namespace 'MLApp' could not be found". How do I add this missing reference?

Best Answer

To resolve this, you will need to add MATLAB Application as a COM reference in your C# project.
  1. First, make sure MATLAB is registered as a COM Automation server.
    • It can be registered by executing 'regmatlabserver' in the MATLAB Command Window.
  2. Add a reference to the MATLAB Application COM object in your C# project. Please follow the below steps for accomplishing this in Visual Studio.
    • From the Project menu, select Add Reference.
    • Select the COM tab in the Add Reference dialog box.
    • Select the MATLAB application.