How to run .net app with using matlab dll?

6 次查看(过去 30 天)
Hi, I'm using the matlab interface for .net 6, so I tried to do everything as stated here
My project file:
My Program.cs file:
When I run application an error pops up:
So I added to my project file this:
and this happening:
What did I do wrong?

回答(1 个)

colordepth
colordepth 2025-2-19
The encountered "MATLABNotAvailableException" error suggests that your PATH environment variable might not be set correctly to find the MATLAB installation. Since you are on a Windows machine, make sure that the directory "<matlabroot>\extern\bin\win64" is included in your system PATH. Replace "<matlabroot>" with the actual path to your MATLAB installation, which might look like 'C:\Program files (x86)\MATLAB\R2022b'. You can find the correct path by running the "matlabroot" command in MATLAB. More details on this command are available at: https://www.mathworks.com/help/releases/R2022b/matlab/ref/matlabroot.html.
To modify your system PATH variable, follow the instructions provided here: https://www.mathworks.com/matlabcentral/answers/223482-how-do-i-set-add-or-change-environment-variables.
It seems you tried to resolve the error by directly referencing DLLs in your C# project file, which could lead to further complications. I suggest removing those direct DLL references from your project. Setting the system path is the recommended method and should resolve the issue without needing those additional references.

类别

Help CenterFile Exchange 中查找有关 Call MATLAB from .NET 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by