VB .NET function use in matlab

4 visualizzazioni (ultimi 30 giorni)
Jean-Marie Roussel
Jean-Marie Roussel il 17 Giu 2022
Risposto: Saarthak Gupta il 14 Dic 2023
Hi all,
I am trying to use a VB .NET dll in matlab. The dll is available from the federal aviation administration website: https://www.airporttech.tc.faa.gov/Products/Airport-Safety-Papers-Publications/Airport-Safety-Detail/ArtMID/3682/ArticleID/2838/ICAO-ACR-13
The dll user guide is attached to this post.
What I tried:
library = NET.addAssembly('[Mypath] \ACRClassLib DLL 2020.12.14 .NET 4.7.2\ACRClassLib.dll');
seems to work. Then:
CalculateACR(1,40000,0.47,4,200,[-15 15 -15 15],[0.0 0.0 55.0 55.0],true)
I get: "Check for incorrect argument data type or missing argument in call to function 'CalculateACR'".
I think the problem is coming from the first argument which is required to be an enumeration member. The enumeration PavementType seems to be included in the library but I don't know how to call it...
Thank you for your answers!
  1 Commento
Daniel Gaffney
Daniel Gaffney il 27 Lug 2023
Did you ever find the answer to this question? I am trying to do the exact same thing.

Accedi per commentare.

Risposte (1)

Saarthak Gupta
Saarthak Gupta il 14 Dic 2023
Hi Jean-Marie,
I understand that you are trying to access an enumeration included in an external .NET Assembly.
In the ‘.NET’ assembly object, ‘PavementType’ is stored as 'ACRClassLib.clsACR+PavementType'.
As per the technical info sheet of the DLL, ‘PavementType’ is an enumeration nested within the clsACR class (which is part of the ACRClassLib namespace), to access such an (nested) enumeration you may use reflection since MATLAB cannot resolve its type.
Reflection is the process of describing the metadata of types, methods, and fields in a code. As per the DOTNET documentation; the classes in the System.Reflection namespace, together with System.Type, enable the user to obtain information about loaded assemblies and the types defined within them, such as classes, interfaces, and value types (that is, structures and enumerations). One can also use reflection to create type instances at run time, and to invoke and access them.
The below code can be used to obtain the required enumeration for your function ‘CalculateACR’:
a = NET.addAssembly("<path-to-file>\ACRClassLib.dll");
% use reflection to get the type of the ‘PavementType’ enumeration
t = a.AssemblyHandle.GetType('ACRClassLib.clsACR+PavementType');
x = ACRClassLib.clsACR;
% construct a 'Flexible' PavementType enumeration object, at runtime
flexiblePavement = System.Enum.ToObject(t,1);
% rigidPavement = System.Enum.ToObject(t,2);
x.CalculateACR(flexiblePavement,0,0,0,0,0,0,0,true);
Please refer to the following MATLAB documentation for further reference:
Hope this helps!
Best Regards,
Saarthak

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by