How to call .dll without header file
조회 수: 10 (최근 30일)
이전 댓글 표시
DLL is generated from C# code. So there's no header file. I want to call this dll from matlab.
Loadlibrary requiries .h file which is not available in my case. What is the best way to run the dll from matlab.?
댓글 수: 0
채택된 답변
Walter Roberson
2025년 5월 7일
The header files is necessary for identifying function "signatures" -- knowing what datatype each function parameter is.
So the answer is "You don't call a C# dll without a header file. Write the header file yourself if need be.
The main alternative is to create the C# as a .NET assembly and use https://www.mathworks.com/help/matlab/ref/net.addassembly.html
추가 답변 (1개)
TED MOSBY
2025년 5월 7일
Hi Kiruthika,
Loadlibrary is only for native (un‑managed) DLLs. A DLL that comes from C# is managed code—a .NET assembly—so you should use MATLAB’s built‑in .NET interface instead of loadlibrary.
dllPath = fullfile('C:\path\to','MyDotNetLib.dll');
asmInfo = NET.addAssembly(dllPath);
Here's a link to the above MATLAB function: https://www.mathworks.com/help/matlab/ref/net.addassembly.html
Hope ths helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!