I am writing a .net assembly in c# using Visual Studio 2022:
using System;
namespace ClassLibrary1
{
public class Class1
{
public int f(int i) { return 3 * i; }
}
}
When I try to load it into MATLAB using the following script:
try
NET.addAssembly(fullfile(pwd, "ClassLibrary1.dll"));
catch ex
end
ex.ExceptionObject.LoaderExceptions.Get(0).Message
I get the error message:
Die Datei oder Assembly "System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
I don't know exactly what the english wording is, something like
Could not load file or assembly "System.Runtime....
The dll-file was locked by MATLAB after this.
I tried creating the assembly using .NET 6.0 as well as .NET core 3.1 in combination with MATLAB 2021b and 2022a, all with the same error message. Just for .NET core, the missing assembly version was
System.Runtime, Version=4.2.2.0
I also tried to consume the assembly with c# console programs, which worked without issues.