Plugin attempts to load dependency again, despite it already being loaded?
I have a .NET (.NET 7, for posterity) hosting from C++ situation. I followed the .NET hosting tutorial and the handoff to my C# DLL works fine. The C# DLL then attempts to load several plugins, and inspect their methods for various attributes.
See attached images.
fhclrhost is the C# DLL that is being hosted, and fhcshook is the plugin. Both of them have a dependency on fhcorlib, which is loaded lazily by fhclrhost, as it is the first to run.
However, when fhcshook is loaded by means of Assembly.LoadFrom(...), it ignores the already loaded fhcorlib and tries to load it again. Why is that? I thought LoadFrom placed things in the same default load context as everything else?
For posterity, fhcshook declares its dependency as in the plugin tutorial on MSDN:
while fhclrhost simply declares its dependency as such:


2 Replies
There should be no version mismatch since these are part of the same solution, and are built at the same time
Solved... it turns out that hosting code makes a very asinine decision.
So what happens is that
fhcorlib was implicitly loaded into that isolated load context, but then Assembly.LoadFrom would load fhcshook into the default ALC
Therefore, no fhcorlib from its perspectiveGitHub
AssemblyLoadContext: requiring full cooperation to stay "inside" is...
Description My overall scenario is that there is a native app, and I want to use .NET 5 C# to write a plugin for that app (see also: #1633). I have tried porting to .NET Core before, but each time ...