I've made a simple dll to demonstrate calling C# from Matlab. When I run with the dll built using .Net Framework 4.7.2 the call to Net.Assembly works as expected. When I call a dll built using .Net Core 3.1 I get the following error message.
"Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
I suspect there may be a Matlab config file that needs to be changed to support this runtime version.
Anyone else run into this problem and have solution?

 採用された回答

David Garrison
David Garrison 2022 年 7 月 13 日

2 投票

Starting In R2022b, on supported Microsoft® Windows platforms, MATLAB will support loading libraries compiled for .NET 5 and higher and for .NET Core, as well as existing support for the Microsoft .NET Framework. You will be able to select a .NET environment, use the dotnetenv function.

4 件のコメント

Michael
Michael 2022 年 7 月 13 日
Excellent news. Thanks.
Thomas Stauffer
Thomas Stauffer 2022 年 8 月 2 日
Is this already supposed to work with the Prerelease R2022b?
David Garrison
David Garrison 2022 年 8 月 2 日
Should be in the R2022b prerelease. Of course, support is for Windows only and you must have .Net 5 or higher installed.
Thomas Stauffer
Thomas Stauffer 2022 年 8 月 3 日
Ok thanks. We can confirm that this works if dotnetenv("core") is called before calling NET.addAssembly.

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

その他の回答 (4 件)

Robert Jack
Robert Jack 2020 年 3 月 23 日

4 投票

I enquired with Matlab support last summer regarding .NET Core / Matlab interop and it is not supported although I was assured that the team were working on it. I've looked at the releases since then (R2019b and R2020a) and MATLAB/.NET core is still not supported and I have not seen any official information released by MATLAB regarding timescales for .NET core support.
This is a bit disappointing as Microsoft are recommending .NET Core for new developments. In fact last week they announced .NET 5 preview 1. As .NET 5 is the next major release of .NET and will unify .NET on a single platform and that this is what they are recommending that all new applications are built with it, it is surprising the Matlab have not got round to supporting .NET core, particularly as it now several years old.

3 件のコメント

Richard Troup
Richard Troup 2020 年 3 月 23 日
Thanks for the response. I really thought this was a problem related to the specific version of .Net Core not that ALL version are not supported.
Robert Jack
Robert Jack 2020 年 3 月 24 日
It would be nice if someone from Mathworks could comment on likely timescales for the support of .NET Core
minibela
minibela 2021 年 3 月 11 日
what about the new version, 2021a, is it supporting .Net Core?

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

Urmila Rajpurohith
Urmila Rajpurohith 2020 年 3 月 24 日

0 投票

As Robert mentioned R2019b, the MATLAB Interface to .NET does not support .NET Core. The developers are considering adding support for this in a future MATLAB release. Please find the current system requirements for using the .NET Interface below.

6 件のコメント

Robert Jack
Robert Jack 2020 年 6 月 11 日
And neither does R2020a. What is the time frame for .NET CORE support? .NET 5 will be released later this year, which is effectively .NET Core. The last released version of .NET Framework (4.8) is over a year old now, and that represents the last version of .NET framework.
Robert Jack
Robert Jack 2020 年 10 月 6 日
.NET 5 is officially being launched at .NET Conf on November 10-12th. This will be the current development track for .NET:- .NET Framework is effectively just in maintainence now. What are Matlab's plans for addressing this?
Richard Troup
Richard Troup 2020 年 10 月 6 日
I agree! Developers need some insight on Matlab's support plan for .Net 5.
Robert Jack
Robert Jack 2021 年 3 月 1 日
Nearly a year has gone by from the original posting and Matlab have not made any official announcement or given any timescale regarding the plans to support .NET 5. .NET 6 is now in preview. It would be nice to hear some kind of update from Mathworks.
David Garrison
David Garrison 2021 年 3 月 31 日
Robert, we are actively working on support for .Net 5. We will support Windows first, then cross-platform. We will support .Net 6 as well. As you probably know, we do not pre-announce feature release dates but we are trying to get .Net 5 support as soon as we can.
Michael
Michael 2022 年 7 月 13 日
Above, @David Garrison mentioned active work on supporting .NET v5. But that was over a year ago. And over two years since this issue was originally raised.
.NET Core has been out for quite a while now, and .NET Standard longer than that. The lack of a resolution to this problem points to the "active work" being shelved or suspended.
While I understand and support the mantra of "we do not pre-announce feature release dates", this is too long. Either actually put some effort into this or outsource it to a competent consultant who can port the code for you ... it isn't rocket science, as anyone with a .NET decompiler can easily see.

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

Robert Jack
Robert Jack 2021 年 3 月 15 日

0 投票

There is nothing in the release notes about .NET Core. Microsoft has announced .NET 6 preview 2 now. It's not obvious that anyone from Matlab looks at these kind of posts very often or has much current interest in supporting .NET Core judging by their level of engagement.

8 件のコメント

Hans Scharler
Hans Scharler 2021 年 3 月 31 日
We're listening. We don't have an update at this time. I will look into it and we will make sure to give an update when we can. Thanks.
Alexander Meiksner
Alexander Meiksner 2022 年 1 月 24 日
Hi Hans,
do you maybe have any news on .NET 5.0 or even .NET 6.0 support for one of the 2022 releases? Thanks a lot!
Robert Jack
Robert Jack 2022 年 1 月 24 日
The release notes for the pre-release of R2022a state:-
On Microsoft Windows platforms, MATLAB supports loading libraries compiled for .NET 5+ and .NET Core, as well as existing support for the Microsoft .NET Framework.
Alexander Meiksner
Alexander Meiksner 2022 年 1 月 25 日
Thanks a lot!
exadev
exadev 2022 年 3 月 14 日
Hi Robert, Hans,
I've just downloaded r2022a and read the release notes.
I can't find any mention of .NET5+ and .NET Core compatibility.
Has the feature been dropped for the actual release?
My newly compiled .NET 5 DLL also doesn't work on r2022a (unlike the old .NET4 DLL that still works fine).
Robert Jack
Robert Jack 2022 年 3 月 14 日
Hi Wabe,
I took the information from the r2022a pre-release notes. As you say, the release notes for r2020a make no mention of .NET Core which is a bit strange.
Can anyone from Matlab comment on this?
Chris Morris
Chris Morris 2022 年 3 月 16 日
I've no information to add, but could I possibly add myself to the list of people this feature would be handy for? dotnet core runs on Linux, which is my target environment for a project I'm working on (which uses matlab as well).
David Garrison
David Garrison 2022 年 8 月 3 日
Support is in R2022b. You can try it in the 22b prerelease

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

heartacker
heartacker 2022 年 4 月 19 日

0 投票

we need this indeed, and what is the ETA

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by