NET.addAssembly .net core 3.1

81 views (last 30 days)
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=, 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?

Accepted Answer

David Garrison
David Garrison on 13 Jul 2022
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.
Thomas Stauffer
Thomas Stauffer on 3 Aug 2022
Ok thanks. We can confirm that this works if dotnetenv("core") is called before calling NET.addAssembly.

Sign in to comment.

More Answers (4)

Robert Jack
Robert Jack on 23 Mar 2020
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.
minibela on 11 Mar 2021
what about the new version, 2021a, is it supporting .Net Core?

Sign in to comment.

Urmila Rajpurohith
Urmila Rajpurohith on 24 Mar 2020
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.
Michael on 13 Jul 2022
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.

Sign in to comment.

Robert Jack
Robert Jack on 15 Mar 2021
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.
David Garrison
David Garrison on 3 Aug 2022
Support is in R2022b. You can try it in the 22b prerelease

Sign in to comment.

heartacker on 19 Apr 2022
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