Main Content

dotnetenv

Change .NET default environment

Since R2022b

    Description

    MATLAB® supports loading .NET assemblies, including:

    • .NET Framework (Microsoft® Windows®)

    • .NET, including .NET Core (Microsoft Windows, macOS, and Linux®)

    For details, see System Requirements for Using MATLAB Interface to .NET. For information about .NET versions compatible with MATLAB, see MATLAB Interfaces to Other Languages.

    To determine if your system has a supported version, use the NET.isNETSupported function. To change the .NET run-time environment, call dotnetenv.

    ne = dotnetenv returns NETEnvironment which contains details about the current .NET run-time environment.

    ne = dotnetenv(version) changes the default .NET version used to load .NET assemblies in MATLAB. The run-time is initialized when you call functions in either NET or System packages.

    example

    Examples

    collapse all

    Load .NET by accessing the System.* namespace.

    netDate = System.DateTime.Now;

    Set the .NET run-time to the latest version.

    ne = dotnetenv("core")
    ne = 
    
      NETEnvironment with properties:
    
                Runtime: core
                 Status: loaded
                Version: ".NET 6.0.25"
        RuntimeLocation: "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.25\"

    Input Arguments

    collapse all

    .NET version, specified as a string or a character vector. Changes the default .NET version.

    • "framework"—Changes the default .NET version to the .NET Framework (Microsoft Windows only).

    • "core"—Changes the default .NET version to the latest version of .NET.

    Version History

    Introduced in R2022b