Resolve Missing Assembly Errors When Using MATLAB Data API with .NET Framework
R2026bYour .NET Framework application might throw a
System.IO.FileNotFoundException for System.Memory or
related assemblies at run time. This error occurs because the MATLAB® Data API for .NET depends on assemblies that are not included with .NET
Framework. This issue does not affect applications built with .NET 6.0 or higher.
To resolve this error, add the required NuGet packages to your project and configure assembly binding redirects.
Add NuGet Packages
In Visual Studio®, right-click your project and select Manage NuGet Packages. On the Browse tab, search for and install the following packages:
System.Memory(version 4.5.4 or later)System.Buffers(version 4.5.1 or later)System.Runtime.CompilerServices.Unsafe(version 5.0.0 or later)
Configure Assembly Binding Redirects
Open the App.config file in your project and add the following
<runtime> element inside
<configuration>. If your project does not have an
App.config file, add one by right-clicking your project in
Solution Explorer, selecting Add >
New Item, and choosing Application Configuration
File.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory"
publicKeyToken="cc7b13ffcd2ddd51"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1"
newVersion="4.0.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers"
publicKeyToken="cc7b13ffcd2ddd51"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0"
newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0"
newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>Verify Package Deployment
Rebuild your project and confirm that the following files appear in your output
folder (bin\Debug or bin\Release):
System.Memory.dllSystem.Buffers.dllSystem.Runtime.CompilerServices.Unsafe.dll
If these files are missing, verify that the NuGet packages installed correctly and that Copy Local is set to True for each package reference.