フィルターのクリア

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

3 ビュー (過去 30 日間)
Jack Arnoldi
Jack Arnoldi 2021 年 2 月 2 日
コメント済み: Jack Arnoldi 2021 年 2 月 3 日
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 件のコメント
Jack Arnoldi
Jack Arnoldi 2021 年 2 月 3 日
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

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler SDK についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by