주요 콘텐츠

Limitations to .NET Support

R2026b

.NET Features Not Supported in MATLAB

MATLAB® supports the .NET features C# supports, with these exceptions:

  • Unloading a .NET Framework assembly. If you modify and rebuild it, you must restart MATLAB to access the new code.

    To unload a .NET Core assembly, call the NET.addAssembly function with the Unloadable parameter set to true, then call NET.unloadAssembly. (since R2026a)

  • Before R2025a: Saving (serializing) .NET objects into a MAT file.

  • Cannot use ClassName.propertyname syntax to set static properties. Use NET.setStaticProperty instead.

  • Passing a structure array, sparse array, or complex number to a .NET property or method.

  • Subclassing .NET classes from MATLAB.

  • Accessing nonpublic class members.

  • Displaying generic methods using methods or methodsview functions. For a workaround, see Display .NET Generic Methods Using Reflection.

  • Creating an instance of a nested class. For a workaround, see Use .NET Nested Classes and Enumerations.

  • Creating .NET arrays with a specific lower bound.

  • Concatenating multiple .NET objects into an array.

  • Implementing interface methods.

  • Hosting .NET controls in figure windows.

  • Casting operations.

  • Calling constructors with ref or out type arguments.

  • Pointer type arguments, function pointers, Dllimport keyword.

  • .NET remoting.

  • Using the MATLAB : (colon) operator in a foreach iteration.

  • Adding event listeners to .NET events defined in static classes.

  • Handling .NET events with signatures that do not conform to the standard signature.

  • Creating empty .NET objects.

  • Creating .NET objects that do not belong to a namespace.

Limitations to Support of .NET Arrays

MATLAB does not support:

  • Arrays which specify a lower bound

  • Concatenating .NET objects into an array

  • The end function as the last index in a .NET array

  • Array indices of complex values

  • Autoconversion of char or cell arrays to jagged array arguments.

  • Autoconversion of MATLAB arrays to multidimensional jagged array arguments.

Limitations to Support of .NET Events

MATLAB only handles events with the standard signature of an event handler delegate

For example, an event handler in C# is a delegate with this signature:

public delegate void MyEventHandler(object sender, MyEventArgs e)

The argument sender specifies the object that fired the event. The argument e holds data that can be used in the event handler. The class MyEventArgs is derived from the .NET class EventArgs.

Limitations to Support of .NET Delegates

MATLAB does not support associating a delegate instance with a generic .NET method.

When calling a method asynchronously, be aware that:

  • MATLAB is a single-threaded application. Therefore, handling asynchronous calls in the MATLAB environment might result in deadlocks.

  • For the technique described in the Microsoft® .NET article Blocking Application Execution Using an AsyncWaitHandle, MATLAB does not support the use of the WaitOne() method overload with no arguments. This technique is supported with Microsoft .NET Framework only.

  • You cannot call EndInvoke to wait for the asynchronous call to complete.

Limitations to Support of .NET Enumerations

You cannot create arrays of .NET enumerations, or any .NET objects, in MATLAB.

See Also

Topics