VB .NET function use in matlab

조회 수: 3 (최근 30일)
Jean-Marie Roussel
Jean-Marie Roussel 2022년 6월 17일
답변: Saarthak Gupta 2023년 12월 14일
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
Daniel Gaffney
Daniel Gaffney 2023년 7월 27일
Did you ever find the answer to this question? I am trying to do the exact same thing.

댓글을 달려면 로그인하십시오.

답변 (1개)

Saarthak Gupta
Saarthak Gupta 2023년 12월 14일
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

카테고리

Help CenterFile Exchange에서 Get Started with Microsoft .NET에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by