Main Content

Common Integration Tasks and Naming Conventions

In Integrate a .NET Assembly Into a C# Application, steps are illustrated that cover the basics of customizing your code in preparation for integrating your deployed .NET component into a large-scale enterprise application. These steps include:

  • Installing the MATLAB® Runtime on end user computers

  • Creating a Microsoft® Visual Studio® project

  • Creating references to the component and to the MWArray API

  • Specifying component assemblies and namespaces

  • Initializing and instantiating your classes

  • Invoking the component using some implicit data conversion techniques

  • Handling errors using a basic try-catch block.

Component Access On Another Computer

To implement your .NET assembly on a computer other than the one on which it was built:

  1. If the component is not already installed on the machine where you want to develop your application, run the self-extracting executable that you created in Generate a .NET Assembly and Build a .NET Application.

    This step is not necessary if you are developing your application on the same machine where you created the .NET assembly.

  2. Reference the .NET assembly in your Microsoft Visual Studio project or from the command line of a CLS-compliant compiler.

    You must also add a reference to the MWArray component in matlabroot\toolbox\dotnetbuilder\bin\architecture\framework_version. See Supported Microsoft .NET Framework Versions for a list of supported framework versions.

  3. Instantiate the generated .NET classes and call the class methods as you would with any .NET class. To marshal data between the native .NET types and the MATLAB array type, you need to use either the MWArray data conversion classes or the MWArray native API.

    Note

    For information about these data conversion classes, see the MATLAB MWArray Class Library Reference, available in the matlabroot\help\dotnetbuilder\MWArrayAPI folder, where matlabroot represents your MATLAB installation folder

    To avoid using data conversion classes, see Implement a Type-Safe Interface.

Component and Class Naming Conventions

Typically you should specify names for assemblies and classes that will be clear to programmers who use the generated code. For example, if you are encapsulating many MATLAB functions, it helps to determine a scheme of function categories and to create a separate class for each category. Also, the name of each class should be descriptive of what the class does.

The .NET naming guidelines recommends the use of Pascal case for capitalizing the names of identifiers of three or more characters. That is, the first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. For example:

 MakeSquare 

In contrast, MATLAB programmers typically use all lowercase for names of functions. For example:

makesquare

By convention, the MATLAB Compiler SDK™ .NET examples use Pascal case.

Valid characters are any alpha or numeric characters, as well as the underscore (_) character.