Why does Matlab crash when I try to access .NET 6.0 (core)?

34 ビュー (過去 30 日間)
Matthew
Matthew 2024 年 11 月 21 日 21:45
コメント済み: Matthew 2024 年 11 月 22 日 14:51
Note: Workaround is to remove .NET 9.0 from PC to resolve conflicts with 6.0.
This might be a .NET issue as a whole, but I only see it using Matlab, so I am posting here to help others out facing the same issues.
I have a .dll from one of the groups I work with for communicating to our devices. The .dll was built in .NET 6.0 (core) (x64). I have been able to use it in the past in Matlab, but have now run into issues since installing Visual Studio 2022. It was discovered that Matlab would reference the most recent installation of .NET (9.0 in my case) which was installed by VS 2022. When I set "core" as the environment in Matlab (dotnetenv("core")), I would then make the .NET assembly visible to Matlab using NET.addAssembly("insert path here"). When Matlab got to this step, it would buffer for about 10 seconds then crash immediately with no crash report. Getting help from my local IT, we pin pointed it to the .NET 9.0 install causing the problem.
To get around this, you can either uninstall 9.0 or set up an environment variable in your system properties called "DOTNET_ROOT" that can force a path to be referenced.
So I would like to ask if anyone else has faced this issue in Matlab? Is it an unexpected error that needs an error handle? I am naive to .net, and really only know the particular dll I interact with to do my methods, etc.

採用された回答

aditi bagora
aditi bagora 2024 年 11 月 22 日 11:17
I have faced the same issue. I found that this issue is specific to .NET 9.0 and does not originate from MATLAB.
After installing Visual Studio 2022, your system updates to the latest version of .NET, which is .NET 9.0 and MATLAB by default, uses the latest version of .NET installed on your system(refer the documentation below), this can lead to a crash. Therefore, uninstalling .NET 9.0 or setting "DOTNET_ROOT" path is solving the issue.
I hope this helps!
  1 件のコメント
Matthew
Matthew 2024 年 11 月 22 日 14:51
Hi @aditi bagora, thanks for providing feedback. I went with the DOTNET_ROOT option on my setup. Glad to see I wasn't doing anything inherently wrong on my end.
@埃博拉酱 thank you. Looks like they aim to have Jan 2025 as a fix release for the bug.

サインインしてコメントする。

その他の回答 (1 件)

埃博拉酱
埃博拉酱 2024 年 11 月 22 日 11:29
This is a known dotnet issue already submitted to Microsoft by MathWorks staff.

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by