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?

 Respuesta aceptada

David Garrison
David Garrison el 13 de Jul. de 2022

2 votos

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 comentarios

Michael
Michael el 13 de Jul. de 2022
Excellent news. Thanks.
Thomas Stauffer
Thomas Stauffer el 2 de Ag. de 2022
Is this already supposed to work with the Prerelease R2022b?
David Garrison
David Garrison el 2 de Ag. de 2022
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 el 3 de Ag. de 2022
Ok thanks. We can confirm that this works if dotnetenv("core") is called before calling NET.addAssembly.

Iniciar sesión para comentar.

Más respuestas (4)

Robert Jack
Robert Jack el 23 de Mzo. de 2020

4 votos

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 comentarios

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

Iniciar sesión para comentar.

Urmila Rajpurohith
Urmila Rajpurohith el 24 de Mzo. de 2020

0 votos

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 comentarios

Robert Jack
Robert Jack el 11 de Jun. de 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.
Robert Jack
Robert Jack el 6 de Oct. de 2020
.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 el 6 de Oct. de 2020
I agree! Developers need some insight on Matlab's support plan for .Net 5.
Robert Jack
Robert Jack el 1 de Mzo. de 2021
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 el 31 de Mzo. de 2021
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 el 13 de Jul. de 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.

Iniciar sesión para comentar.

Robert Jack
Robert Jack el 15 de Mzo. de 2021

0 votos

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 comentarios

Hans Scharler
Hans Scharler el 31 de Mzo. de 2021
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 el 24 de En. de 2022
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 el 24 de En. de 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.
Alexander Meiksner
Alexander Meiksner el 25 de En. de 2022
Thanks a lot!
exadev
exadev el 14 de Mzo. de 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 el 14 de Mzo. de 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?
Chris Morris
Chris Morris el 16 de Mzo. de 2022
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 el 3 de Ag. de 2022
Support is in R2022b. You can try it in the 22b prerelease

Iniciar sesión para comentar.

heartacker
heartacker el 19 de Abr. de 2022

0 votos

we need this indeed, and what is the ETA

Preguntada:

el 18 de Mzo. de 2020

Comentada:

el 3 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by