ARTICLE AD BOX
I have almost completed a migration of our .NET 4.6 app to .NET 10.
Everything looks ok except one thing: in the .NET Framework, we used the <probing privatePath="lib" /> value in the app.exe.config file and it worked great. We could remove all third party libraries int this folder and clean our main directory.
But in the new .NET 10, it's a tons of pain. I wanted to resolve the probing path via the code
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve, AppDomain.CurrentDomain.AssemblyResolve, AppDomain.CurrentDomain.TypeResolve, AssemblyLoadContext.Default.Resolvingbut it does not work as expected: referenced assemblies are not loaded/resolved in the Main() function.
A small code example:
static Program() { MessageBox.Show("Start"); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; AppDomain.CurrentDomain.TypeResolve += CurrentDomain_TypeResolve; AssemblyLoadContext.Default.Resolving += Default_Resolving; } [STAThread] static void Main() { InitApp(); Application.Run(new frmMain()); }Application is NOT running into the constructor (MessageBox.Show("Start") is not executed).
So I have silent application crash and the following message in the Event Log:

It happens even if the Main() function is totally empty.
So it feels like the dotnet tries to load all referenced dll BEFORE actual application start:

At the same time everything works fine if I locate all related dlls in the application folder.
Also AppDomain.CurrentDomain.AssemblyResolve works perfectly into Dll project migrated from .NET 4.6 to .NET 10, we call this dll via the COM interop from MFC Exe file. In this case AssemblyResolve fires for every reference.
I tried to use additionalProbingPaths (no luck).
"runtimeOptions": { "framework": { "name": "Microsoft.NETCore.App", "version": "2.0.0" }, "additionalProbingPaths": ["./Lib/AppDlls"] }Theoretically, I can change paths in the .deps.json file, but I would like to avoid this.
I tried to use the PROBING_PATH in the runtime config.
In the tracelog I see that dotnet tries to find dlls in my root folder only:

Guys, I have no idea what to do else. I hope maybe you will advise me.
Thanks a lot.
