Main Content

NET.addAssembly

Make .NET assembly visible to MATLAB

Description

asmInfo = NET.addAssembly(globalName) loads a global .NET assembly into MATLAB®.

If you load a .NET Core assembly, you can unload it by calling NET.unloadAssembly. If you modify and rebuild a .NET Framework assembly, you must restart MATLAB to access the updated code. (since R2025a)

example

asmInfo = NET.addAssembly(privateName) loads a private .NET assembly.

Examples

collapse all

First, load the global assembly System.Windows.Forms into MATLAB. Then import and call the System.Windows.Forms.MessageBox.Show method in the global assembly System.Windows.Forms.

asmInfo = NET.addAssembly("System.Windows.Forms");
import System.Windows.Forms.*
MessageBox.Show("Simple Message Box")

Input Arguments

collapse all

Global assembly name, specified as a string scalar, character vector, or System.Reflection.AssemblyName object.

Private assembly name including the full path, specified as a string scalar or character vector.

Output Arguments

collapse all

Assembly information containing names of the members of the assembly, returned as a NET.Assembly object.

Limitations

  • NET.addAssembly does not support assemblies generated by the MATLAB Compiler SDK™ product.

Tips

  • You do not need to call NET.addAssembly to access classes in the mscorlib.dll and system.dll assemblies. MATLAB dynamically loads these assemblies from the .NET class library the first time you type "NET." or "System.".

  • Refer to your .NET product documentation for the name of the assembly and its deployment type (global or private).

Version History

Introduced in R2009a

See Also

Functions

  • NET.unloadAssembly

Objects