Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Jack Arnoldi
Jack Arnoldi le 2 Fév 2021
Commenté : Jack Arnoldi le 3 Fév 2021
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 commentaire
Jack Arnoldi
Jack Arnoldi le 3 Fév 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Compiler SDK dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by