Borrar filtros
Borrar filtros

C# return an error when trying to use Matlab function generated with compiler SDK

3 visualizaciones (últimos 30 días)
Hello everyone,
I am trying to discover the Matlab Compiler SDK. So I used a function that I previously coded and removed all inputs and outputs to have it look like :
function traj2D_plot5()
This function does some calculation then generates a csv file (with csvwrite) and displays a plot3 and a scatter3 figure.
With the Matlab Compiler SDK I generated the .Net files from this function. Which gave me two dlls located in the for_redistribution_files_only folder:
traj2D_plot5.dll traj2D_plot5Native.dll
I referenced these two dlls in my C# project as long as the Matlab Runtime.
I then went in the for_testing folder to get the traj2D.cs file (I specified the class name as traj2D in the Matlab Compiler) that I added in my project as well. I was (and am still) surprised to see the C# files and the dlls did not really look like the video tutorial but there is a constructor in the traj2D.cs file so I went for it anyway.
I have a button designed in my C# project so in that button I wanted to call the class and launch the function kind of like in the video tutorial. So I wrote two simple lines of C# code :
traj2D_plot5.traj2D traj = new traj2D_plot5.traj2D();
traj.traj2D_plot5();
However, if everything compiles in my project when I click my button and it calls the first line my system returns this error :
System.TypeInitializationException : 'An exception has been raised by the type initialiser for 'traj2D_plot5.traj2D'.'
BadImageFormatException : Attempt of loading a program with incorrect format. (Exception de HRESULT : 0x8007000B)
So I have no idea how to simply run the matlab function and I am having trouble finding complete documentation on the subject. So if anyone can help me on this problem I will be very much thankful.
  1 comentario
Jack Arnoldi
Jack Arnoldi el 3 de Feb. de 2021
I found the problem. My project was compiling for "any cpu" while it had to be x64.
As for the documentation you can find it there : Génération du composant .NET or here : en pdf

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB Compiler SDK en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by