Main Content

Generate the Type-Safe API with an Assembly

Use the Library Compiler App

The Library Compiler app generates the type-safe API, when you build your assembly, if the correct options are selected.

  1. Create a Library Compiler project.

  2. Select .NET Assembly from the Type list.

  3. Expand the Additional Runtime Settings section.

  4. In the Type-Safe API section, do the following:

    1. Select Enable Type-Safe API.

    2. In the Interface assembly field, specify the location of the type-safe/WCF interface assembly that you built.

    3. Select the desired interface from the .NET interface drop-down box.


      If the drop-down is blank, the Library Compiler app may have been unable to find any .NET interfaces in the assembly you selected.

    4. Specify the name of the class you want the generated API to wrap, in the Wrapped Class field.


    Leave the Namespace field blank.

  5. Build the project by clicking the Package button.

Use the Command-Line Tools

To generate the type-safe API with your component using mcc, do the following:

  1. Build the component by entering this command from MATLAB®:

    mcc -v -B 'dotnet:AddOneComp,Mechanism,3.5,private,local'

    See the mcc reference page for details on the options specified.

  2. Generate the type-safe API by entering this command from MATLAB:

    ntswrap -c AddOneComp.Mechanism -i IAddOne -a IAddOne.dll


    • -c specifies the namespace-qualified name of the .NET assembly to wrap with a type-safe API. If the assembly is scoped to a namespace, specify the full namespace-qualified name (AddOneComp.Mechanism in the example). Because no namespace is specified by ntswrap, the type-safe interface class appears in the global namespace.

    • -i specifies the name of the .NET interface that defines the type-safe API. The interface name is usually prefixed by an I.

    • -a specifies the absolute or relative path to the assembly containing the .NET statically-typed interface, referenced by the -i switch.


      If the assembly containing the .NET interface IAddOne is not in the current folder, specify the full path.


    Not all arguments are compatible with each other. See the ntswrap for details on all command options.