1
votes

I want to compile some Matlab code in Matlab Builder NE.
In this code, I want to call .NET assemblies, using Matlab built-in ability to use .NET components : http://www.mathworks.com/help/techdoc/matlab_external/brpb58s-1.html
The process is like that:

  1. C# calls Matlab compiled .NET DLL
  2. MCR uses .NET assemblies to do something (As described above)
  3. MCR returns answer to C#

Here is a Matlab code sample that is being compiled to .NET component, with .NET4 as target

function ver = GetVersion()
    NET.addAssembly('System');
    ver = char(System.Environment.Version.ToString())};
end

However, when this simple code is compiled, by taking a look at ver,I am realizing that it uses .NET 2 instead of .NET 4.

When I use it directly from Matlab, I get version 4.
How can I control the .NET runtime version in compiled DLLs?

1

1 Answers

1
votes

on the same computer?The command "mcc" make a version of the latest supported version on the target machine.You can choose a version.

Just now I have a test with my computer,User mcc to set the version of .Net 2.0 to complier

mcc -W 'dotnet:TestVersion,Version,2.0,private' -d 'C:\Users\HW-WIN7-TEMP\Documents\MATLAB\TestVersion\src' -T 'link:lib' -v 'class{Version:C:\Users\HW-WIN7-TEMP\Documents\MATLAB\GetVersion.m}'

And I use target version 3.5 to run my C# program.Get the same result.

ver = GetVersion() ver = 2.0.50727.5448