NET.addAssembly .net core 3.1

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?

 Risposta accettata

David Garrison
David Garrison il 13 Lug 2022

2 voti

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 Commenti

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

Accedi per commentare.

Più risposte (4)

Robert Jack
Robert Jack il 23 Mar 2020

4 voti

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 Commenti

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 il 24 Mar 2020
It would be nice if someone from Mathworks could comment on likely timescales for the support of .NET Core
minibela
minibela il 11 Mar 2021
what about the new version, 2021a, is it supporting .Net Core?

Accedi per commentare.

Urmila Rajpurohith
Urmila Rajpurohith il 24 Mar 2020

0 voti

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 Commenti

Robert Jack
Robert Jack il 11 Giu 2020
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.
.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?
I agree! Developers need some insight on Matlab's support plan for .Net 5.
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.
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 il 13 Lug 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.

Accedi per commentare.

Robert Jack
Robert Jack il 15 Mar 2021

0 voti

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 Commenti

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.
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 il 24 Gen 2022
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.
Thanks a lot!
exadev
exadev il 14 Mar 2022
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 il 14 Mar 2022
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?
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).
Support is in R2022b. You can try it in the 22b prerelease

Accedi per commentare.

heartacker
heartacker il 19 Apr 2022

0 voti

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