Main Content

.NET Assembly Integration

Integrate compiled MATLAB® functions into .NET applications

With MATLAB Compiler SDK™, integrating compiled MATLAB functions into a .NET application involves using a combination of APIs that initialize MATLAB Runtime, load the compiled MATLAB functions into MATLAB Runtime, and manage the data that passes between the .NET code and MATLAB.

The two data conversion APIs that marshal and format data between .NET and MATLAB are MWArray, which uses derived types that map to MATLAB data types, and the native .NET API, which uses native .NET types and supports .NET remoting. In addition, type-safe interfaces provide an alternate set of methods that work directly with native .NET data types.

To integrate MATLAB functions with servers developed in .NET, use either the .NET remoting API or the Windows Communications Foundation framework from Microsoft®. These APIs facilitate the development of distributed applications with features for deploying active figures over the web and accessing .NET remoting capabilities.

Functions .NET assembly for deployment outside MATLAB for building .NET assemblies
compiler.package.installerCreate an installer for files generated by MATLAB Compiler
compiler.package.InstallerOptionsOptions for creating MATLAB Compiler package installers
enableTSUtilsfromNetworkDriveSet trust setting to load .NET assemblies from network drive
ntswrapGenerate type-safe API

MWArray Class Library Reference


Create and Integrate with .NET Framework

Generate .NET Assembly and Build .NET Application

Create a .NET assembly in MATLAB and implement it with sample C# code.

Integrate .NET Assembly Into F# Application

Use F# to integrate your assembly with less code.

Create and Integrate with .NET Core

Build .NET Core Application That Runs on Linux and macOS

Create a .NET core application that can run on UNIX® systems.

Sample Applications

Integrate Simple MATLAB Function Into .NET Application

Build a .NET application using C# or Visual Basic®.

Integrate Function with Variable Number of Arguments

Build a .NET application using a MATLAB function that takes a variable number of arguments.

Assign Multiple MATLAB Functions in Component Class

Create a .NET assembly containing multiple functions to implement a matrix math program.

Integrate MATLAB Optimization Routines with Objective Functions

Build a .NET assembly that applies optimization routines to objective functions using the MWObjectArray class.

Use Multiple Classes in .NET Assembly

Create a .NET assembly containing multiple classes to implement a signal analyzer application.

Block Console Display When Creating Figures

Handle interaction in a console-based program that creates MATLAB figures.

Data Conversion

Data Marshaling with MWArray API

Learn how the MWArray classes convert data between .NET and MATLAB.

Convert Data Between .NET and MATLAB

See examples on manually converting between native .NET data types and MATLAB types.

Rules for Data Conversion Between .NET and MATLAB

Refer to the rules for converting .NET types to MATLAB types.

Interfaces Generated by the MATLAB Compiler SDK

Learn the different class methods generated for each MATLAB function.

Limitations on Multiple Assemblies in Single Application

See the data types that cannot be shared across .NET assemblies.

Type-Safe API

Type-Safe Interfaces

Consider using type-safe interfaces instead of MWArray to work directly with native data types.

Implement Type-Safe Interface and Integrate into .NET Application

Create a multiplication program that uses native .NET data types through a type-safe interface.

Create Managed Extensibility Framework Plug-Ins

Extend .NET applications with Managed Extensibility Framework (MEF) plug-ins using a type-safe API.

.NET Remoting

Create Remotable .NET Assembly

Build a remotable .NET component using the Library Compiler app or programmatically.

Compare MWArray and Native .NET API for Remotable Assemblies

Decide between the MWArray and native .NET APIs for data marshaling in an assembly.

.NET Remoting and Windows Communications Foundation

Learn the advantages of implementing remotable .NET components.

Create Windows Communications Foundation Component

Deploy a Windows® Communications Foundation (WCF) component using a type-safe API.