Unrecognized function or variable error, when calling MATLAB .dll function from C#

1 view (last 30 days)
I could not find answer that would help, I hope I am just missing something. I am trying to call a function from dlls generated by the MATLAB Compiler. Redacted C# code below shows the call. (Bonus points if someone can tell in advance that P variable will lead to another error and how to address it)
int[] aPOI = new int[2];
aPOI[0] = 560;
aPOI[1] = 560;
MathWorks.MATLAB.NET.Arrays.MWNumericArray P = aPOI;
MathWorks.MATLAB.NET.Arrays.MWArray mWArray1 = mtf.M(mWArray, f, (MathWorks.MATLAB.NET.Arrays.MWArray)P);
and when called, it leads to following errors:
Unrecognized function or variable 'MidPnt'.
Error in FR (line 65)
Error in C_F (line 30)
Error in M (line 14)
Exception thrown: 'System.Exception' in MWArray.dll
The call hierarchy looks approximately like this::
function [T] = M(I, F, POI)
Disp = 0;
if ~(isdeployed)
addpath('Common');
addpath('Utility Functions');
end
[r_m, DI, bI] = C_F(I,pR,POI);
function [r_m, DI, bI] = C_F(I, pR,POI)
if ~(isdeployed)
addpath('Common');
end
[h, v, C, bI] = FR(I, 0);
cC = FC(Co,POI(1),POI(2),true);
[h, v] = FE(cC,h, v);
vST = MSFSE( vSER, pR, 0.15 );
function [h, v, C, bI] = FR(I, D)
if ~(isdeployed)
addpath('Common');
end
p1 = MidPnt( Corners(r, c), Corners(r, c+1), 1, 4 );
function sharpnessTable = MSFSE(SER, pR, mC )
if ~(isdeployed)
addpath('sf3');
end
dat = sf3(1,1,[], SER(i).RI);
with
sf3 located in sf3\sf3.m
MidPnt located at Common\midPnt.m
and FC and FE in Utility Functions\FC.m and Utility Functions\FE.m respectively
I added the isdeployed check, as addpath kept throwing warnings in the C# code.
I do not have access to the MATLAB Compiler, I only send the code and get the installer back.
I assume that dependencies are not located properly when compiling, but why is that? Would I be correct in assuming, that only reason this doesn't happen for FC, FE and sf3 functions is because it doesn't get there?
Anybody can guess where the problem is?
Thanks for any help

Answers (1)

Kojiro Saito
Kojiro Saito on 26 May 2022
MidPnt is located in Common folder but the dll packaged from MATLAB Compiler SDK does not contain the files.
In compiling, sf3, Common and Utility Functions folders should be included in AdditionalFiles property of
compiler.build.dotNETAssembly (command line), or in "files required for your library to run" of Library Compiler GUI.
>Would I be correct in assuming, that only reason this doesn't happen for FC, FE and sf3 functions is because it doesn't get there?
No. The dll fails in the following code. And MATLAB Runtime exited.
[h, v, C, bI] = FR(I, 0);
So, the sequent commands are not exeuceted, so the errors of FC, FE and sf3 not occurred.
cC = FC(Co,POI(1),POI(2),true);
[h, v] = FE(cC,h, v);
vST = MSFSE( vSER, pR, 0.15 );

Categories

Find more on Get Started with MATLAB Compiler SDK in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!