.NET addAssembly fail
이전 댓글 표시
The code
A = NET.addAssembly('C:\path\to\mydll.dll')
fails with the hint 'source: mscorlib'.
After some searching, I tried to capture the exception using
try
NET.addAssembly('C:\path\to\mydll.dll')
catch ex
end
But the ex.ExceptionObject has no field LoaderException:
>>> ex.ExceptionObject.LoaderExceptions.Get(0).Message
No appropriate method, property, or field 'LoaderExceptions' for class 'System.IO.FileLoadException'.
How can I get access to the LoaderException?
//EDIT: I pinned it down: mydll.dll depends on a version of hdf5.dll which is situated in the same folder as mydll.dll. If I comment out all statements relying on hdf5.dll from the source of mydll.dll, the import works. Could it be that MATLAB is working with another version of hdf5.dll it found somewhere else? I tried 1) adding the folder with my version to the path 2) copying hdf5.dll to /system32.
댓글 수: 7
Siddharth Bhutiya
2018년 9월 19일
Could you post the complete error message that you get when you try to add the assembly without using try-catch.
Also are you able to load it outside MATLAB?
This error could be due to some missing dependencies for your dll. If they are not present in the current folder then MATLAB will not be able to locate them and might throw this error
Guillaume
2018년 9월 20일
It does sound like a dependency of your library is either not found or for some reason fails to load properly.
Siddharth Bhutiya
2018년 9월 20일
When you tried running it in C# did you add any references ?
There might be files on the linkerpath and inlcudepath which might be needed for your DLL.
Also could you please post the type of the exception object by displaying it after the try catch block.
disp(ex)
This might give us some insights.
fablukm
2018년 9월 21일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Microsoft .NET에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!