Debugging .NET Assembly Load
Show older comments
I am struggling with loading a .NET 8 library assembly into matlab. I keep getting errors like the following:
Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
After attempting the load, I check the .NET environment and I get the following:
>> dotnetenv
ans =
NETEnvironment with properties:
Runtime: framework
Status: loaded
Version: ".NET Framework 4.0.30319.42000"
RuntimeLocation: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\"
Why is it loading the .NET Framework if the assembly is .NET 8? I created a new C#, .NET 8 library in Visual Studio. It has only one class with a couple of properties. The results above are from attempting to load this project.
Since the error occurs during loading, there's nothing for Visual Studio debugger to attach to. Is there a way to debug the assembly loading in Matlab or is this a .NET issue? The only other option I can think of is to start shotgun loading various dependencies trying to find the right sequence to load things, but that will be very painful.
EDIT
I downloaded Fusion++ and been trying to diagnose the way Matlab is attempting to load these assemblies. One thing I've discovered is a difference between a self-contained and framework-dependent build in .NET. When creating a self-contained library the error you get is:
Message: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.
Source: mscorlib
HelpLink: None
When creating a framework-dependent library it's a slightly different error.
Message: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source: mscorlib
HelpLink: None
It seems it can find the .NET 8 runtime in the self-contained build, but fails on some subsequent dependency.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Microsoft .NET in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!