Copy the example files as follows depending on whether
you plan to use the MWArray API or the native .NET
API:
If using the MWArray API, copy the following folder that ships with the MATLAB® product to your working folder:
matlabroot\toolbox\dotnetbuilder\Examples\VSVersion\NET\MagicRemoteExample\MWArrayAPI\MagicSquareRemoteComp
After you copy the files, at the MATLAB command prompt,
change the working directory (cd) to the new MagicSquareRemoteComp subfolder
in your working folder.
If using the native .NET API, copy the following folder that ships with the MATLAB product to your working folder:
matlabroot\toolbox\dotnetbuilder\Examples\VSVersion\NET\MagicRemoteExample\NativeAPI\MagicSquareRemoteComp
After you copy the file, at the MATLAB command prompt,
change the working directory (cd) to the new MagicSquareRemoteComp subfolder
in your working folder.
Write the MATLAB function Your MATLAB code
does not require any additions to support .NET Remoting. The following
code for the makesquare function is in the file makesquare.m in
the MagicSquareRemoteComp subfolder:
function y = makesquare(x) y = magic(x);
Click the Library Compiler app in the apps gallery.
In the Additional Runtime Settings area, select Enable .NET Remoting.

Build the .NET component. See the instructions in Create a .NET Assembly for more details.
From the MATLAB prompt, issue the following command:
mcc -B "dotnet:CompName,ClassName, FrameworkVersion,ShareFlag, RemoteFlag"
CompName is the name of
the component you want to create.
ClassName is the name of
the C# class to which the component belongs.
FrameworkVersion is the
version of .NET Framework for the component you are building. For
example, 2.0 would denote .NET Framework 2.0.
designates
access to the component. Values are either ShareFlagprivate or shared.
Default is private.
designates
either a remote or local component. Values are either RemoteFlagremote or local.
Default is local.
To build a private remotable component, the mcc command
to build the component for the .NET 2.0 Framework will look similar
to:
mcc -B "dotnet:MagicSquareComp,MagicSquareClass,2.0,
private,remote"After compiling the components, ensure you have the following
files in your for_redistribution_files_only folder:
MagicSquareComp.dll — The MWArray API
component implementation assembly used by the server.
IMagicSquareComp.dll — The MWArray API
component interface assembly used by the client .
MagicSquareCompNative.dll —
The native .NET API component implementation assembly used by the
server.
IMagicSquareCompNative.dll —
The native .NET API component interface assembly used by the client.
You do not need to install a MATLAB Runtime on the client when
using this interface.