Main Content

Setting Up .NET Development Environment

To integrate MATLAB® code into .NET applications, start by authoring your MATLAB code using the MATLAB desktop. Then, utilize MATLAB Compiler SDK™ to generate .NET components. Finally, complete the integration process in your preferred C# development environment, including a text editor along with the .NET SDK Command Line API or Microsoft® Visual Studio® on Windows® and macOS.

The files you need to include in your setup depend on whether you're using the modern MATLAB Data API for .NET or the legacy MWArray API.

.NET Command Line API

Use the .NET SDK command-line interface (CLI) along with a code editor to integrate MATLAB code within .NET applications. You must use .NET 6.0 or higher. You can verify whether .NET 6.0 is installed by typing dotnet --info at a system command prompt. For details, see .NET CLI Overview.


Add the following assembly dependencies to your project:

  • MathWorks.MATLAB.Runtime.dll

  • MathWorks.MATLAB.Types.dll

 Windows Paths to MathWorks Assemblies

 Linux and macOS Paths to MathWorks Assemblies

Edit the project file (.csproj) and add the above references using the <ItemGroup> tag. For example:

<Project Sdk="Microsoft.NET.Sdk">
    <Reference Include="MathWorks.MATLAB.Runtime">
      <HintPath>C:\Program Files\MATLAB\MATLAB Runtime\R2023b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Runtime.dll</HintPath>
    <Reference Include="MathWorks.MATLAB.Types">
      <HintPath>C:\Program Files\MATLAB\MATLAB Runtime\R2023b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Types.dll</HintPath>


Add the following assembly dependency to your project:

  • MWArray.dll

 Windows Paths to MWArray Assembly

Microsoft Visual Studio

If you use Visual Studio for integration, first verify that you have installed Microsoft Visual Studio 2022 (v17.0 or higher).


Add the MathWorks® assemblies listed above from the Solution Explorer:

  • In Solution Explorer, right-click on the Dependencies node and choose Add Project Reference.

  • Browse for the MathWorks assembly dependencies mentioned above in the Reference Manager and add them.

Setting PATH Environment Variable

Before executing your C# application in Visual Studio, ensure that your PATH environment variable is correctly set to reference your MATLAB or MATLAB Runtime installation. Here's how you can set the PATH environment variable within Visual Studio:

  1. In Visual Studio, right-click your project in Solution Explorer, then click Properties.

  2. Navigate to Debug > General, and select Open debug launch profiles UI.

  3. In the Launch Profiles window, under Environment variables, set your PATH:

    • For MATLAB:

      PATH=C:\Program Files\MATLAB\R2023b\runtime\win64
    • For MATLAB Runtime:

      PATH=C:\Program Files\MATLAB\MATLAB Runtime\R2023b\runtime\win64


Add the MWArray.dll assembly as a reference from one of the following locations.

 Windows Paths to MWArray Assembly


You can test your .NET application against the installed version of MATLAB that was used to generate the .NET artifacts or against an installation of MATLAB Runtime. However, during deployment you must use MATLAB Runtime.

Related Topics

External Websites