.NET Assembly Compiler
Description
The .NET Assembly Compiler packages MATLAB® programs into .NET assemblies that you can integrate into .NET applications.
The interactive menus and dialog boxes used in the compiler apps build
compiler.build commands that are customized to your
specification.
Compiler app advantages include:
You can perform deployment tasks with a single intuitive interface.
You can organize your files in a MATLAB project.
Your project state persists between sessions.
You can load previously stored compiler tasks from a prepopulated menu.
You can package applications with an installer for distribution.
For more information, see Target-Specific Compiler Apps for MATLAB Code Deployment.
Open the .NET Assembly Compiler App
MATLAB toolstrip: On the Apps tab, under Application Deployment, click the app icon.
MATLAB command prompt: Enter
dotNetAssemblyCompiler.
Examples
Parameters
Exported Functions
Files implementing MATLAB functions. Files must have one of the following extensions:
.m, .p, .mlx, or
.mexa64.
All files must be located in the project root folder to be added to the
project. To add MATLAB functions to the deployable archive., click Add Exported
Function and select your MATLAB file. In the Project panel, the file you selected gains the labels
Design and Exported Function File.
.NET Assembly Info
Name of the generated .NET assembly.
Version number of the package.
Name of application author.
Email address of the application author.
Name of company that created the application.
Summary description of the package, specified as a character vector or a string scalar.
Detailed description of the package, specified as a character vector or a string scalar.
Output Locations
Path to folder where the build artifacts are generated.
Path to folder where the installer is generated.
If you enable this property, then debugging symbol information is included in the compiled artifact. This option also causes
mbuildto pass appropriate debugging flags to the system compiler. The debug option lets you back trace up to the point where you can identify if the failure occurred in the initialization of MATLAB Runtime, the function call, or the termination routine. This option does not let you debug your MATLAB files with an external debugger.If you disable this property, then debug symbols are not included. This is the default option.
Build Settings
In the .NET API Selection section, choose the API to use for exchanging data between the .NET application and the MATLAB functions.
Choosing a .NET deployment option comes down to understanding the capabilities
of each option and recognizing how those capabilities line up with your
development requirements. Both options provide a comprehensive set of APIs for
handling both application management and data manipulation. MathWorks® recommends using the more modern MATLAB Data API over the mwArray API. For more
information, see Choose C++ Deployment Option.
If you enable this option, then folder structures and file names in the
deployable archive are obfuscated from the end user, and user code and data
contained in .m, .mlapp,
.p, .mat, MLX, SFX, and MEX files are
placed into a user package within the archive. Additionally, all
.m files are converted to P-files before packaging.
During runtime, MATLAB code and data is decrypted and loaded directly from the user package rather than extracted to the file system. MEX files are temporarily extracted from the user package before being loaded.
To manually include additional file types in the user package, add each file
type in a separate extension tag to the file
.matlabroot/toolbox/compiler/advanced_package_supported_files.xml
The following are not supported:
verfunctionCalling external libraries such as DLLs
Out-of-process MATLAB Runtime (C++ shared library for MATLAB Data Array)
Out-of-process MEX file execution (
mexhost,feval,matlab.mex.MexHost)Before R2023b:
.matfiles other than v7.3
Enabling this option is equivalent to using mcc with
-j and -s specified.
If you set this parameter to 'off', then the deployable
archive is not obfuscated. This is the default behavior.
Files Required for the .NET Assembly to Run
Support packages to include in the deployable archive. The dependency analysis
process detects and includes the required support packages automatically. Only the
specified support packages are included. To list installed support packages or
those used by a specific file, see compiler.codetools.deployableSupportPackages.
Additional files and folders to include in the deployable archive. To add the contents of a folder, click Add Folder. To add an individual file, click Add File.
Additional files to include in the deployable archive. The dependency analysis process detects and includes required data files automatically unless Automatically include data files that are provided as inputs to functions such as load and fopen is disabled.
To view the file analysis results, click View Analysis. To perform the dependency analysis process again, click Reanalyze.
Automatically include data files in the deployable archive.
If you enable this property, then data files that you provide as inputs to certain functions (such as
loadandfopen) are automatically included in the deployable archive. This is the default option.If you disable this property, then you must add data files to the package in the Custom Requirements section.
Samples
Generate and modify sample MATLAB files, which are compiled into .NET code that demonstrates how to call a MATLAB exported function in the target language.
For each MATLAB sample file you include during packaging, a sample application in
the target language is generated in a folder named samples.
These samples are also included in the installer.
To upload a MATLAB script you have already written, click Add existing sample.
To generate a new MATLAB sample file, click Create new sample. This opens up a MATLAB script for you to edit. After packaging, the generated sample code calls your exported function using the same arguments as in the sample MATLAB script.
For more information, see Create Sample Code to Call Exported Function.
Installer Details
MATLAB Runtime delivery option, specified as one of the following.
Fetch MATLAB Runtime from mathworks.com during application installation — Option for the installer to download MATLAB Runtime from the MathWorks website during application installation. This option is the default behavior.
Include MATLAB Runtime in application installer for offline installation — Option to include MATLAB Runtime within the installer so that it can be installed during application installation without connecting to the MathWorks website. Use this option if you think your end user might not have access to the internet.
Do not include MATLAB Runtime in application installer — Option to not install MATLAB Runtime during application installation. Use this option if you think your end user will install MATLAB Runtime using another method. (since R2024a)
Note
If you use either the Fetch or Include option, the full MATLAB Runtime will be installed. To create a minimal MATLAB Runtime installer that can run one or more specific MATLAB Runtime applications, see compiler.runtime.customInstaller. (since R2024b)
Name of the generated installer.
Path to folder where the application will be installed. The folder is located in the %ProgramFiles% folder of the target machine.
Notes about additional requirements for using the application.
Image file used as the installer splash screen, specified as a character vector or a string scalar. The splash screen icon will be resized to 400 pixels by 400 pixels.
Image file used as the icon for the installer.
Image file used as the installer logo, specified as a character vector or a string scalar. The logo will be resized to 112 pixels by 290 pixels.
Version History
Introduced in R2025aIn R2024b and earlier releases, you can generate .NET assemblies using the Library Compiler. Starting in R2025a, use the .NET Assembly Compiler to create .NET assemblies.
In R2024b and earlier releases, the compiler apps generate output files in the
folders for redistribution, for
redistribution_files_only, and for testing. Starting in
R2025a, the compiler apps generate output files in a folder named after the compiler
task.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)