How to run .net app with using matlab dll?
6 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
colordepth
on 19 Feb 2025
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.
0 Comments
See Also
Categories
Find more on Call MATLAB from .NET in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!