-
I'm porting an MFC C++/CLI app from .NET Framework to .NET 8. The entry EXE used to be mixed-mode, but that's not allowed in .NET [Core], so I converted the main project to a DLL and created a fully-native shell exe whose sole class extends one exported from the mixed-mode DLL. The mixed-mode DLL is implicitly linked via an import library; I don't load it explicitly with a call to LoadLibrary(). After the discussion here and here I expected the mixed-mode code to find itself loaded into the default AssemblyLoadContext, but when I check, I find it's in an isolated AssemblyLoadContext. I'm trying to guarantee that all the .NET code in my app, which includes several C++/CLI assemblies as well as pure .NET assemblies, gets loaded into the default AssemblyLoadContext. Is this possible with a native app and implicit linking? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
/cc @elinor-fung |
Beta Was this translation helpful? Give feedback.
-
@adv12 Your expectation is correct - we should be loading the C++/CLI library in the default ALC regardless of whether it is used via an import library or an explicit LoadLibrary call.
I did modify the basic sample in dotnet/samples to target net8.0 and show the ALC - that showed loading in the default ALC, so I suspect there may be something more complicated going on in your scenario. |
Beta Was this translation helpful? Give feedback.
-
This was user error. I had started the projects as .NET 6 and upgraded them to .NET 8 RC. I wasn't running out of the target directory but a bin directory to which all the projects copy their output in a post-build event. Ijwhost.dll wasn't getting copied to the bin directory, and the copy there was stale (from .NET 6). When I copied the .NET 8 Ijwhost.dll to the bin directory, I got the default ALC. Sorry for the distraction. |
Beta Was this translation helpful? Give feedback.
This was user error. I had started the projects as .NET 6 and upgraded them to .NET 8 RC. I wasn't running out of the target directory but a bin directory to which all the projects copy their output in a post-build event. Ijwhost.dll wasn't getting copied to the bin directory, and the copy there was stale (from .NET 6). When I copied the .NET 8 Ijwhost.dll to the bin directory, I got the default ALC.
Sorry for the distraction.