Issue
HostFxr fails to Initialize the host context when tried from a Native Code which is a Part of another .Net App.
we are trying to achieve a requirement where ASP.NetCore/.Net Core App loads a Linux .So by PInvoke and that Linux .So in turn tries to load another Managed Assembly. This is where the issue Occurs.
Target Platform is Linux or WSL.
When the Core App starts in Linux, It gives error saying ( Success_HostAlreadyInitialized) (0x00000001) and there is no Hostfxr context handle.
When the Same Core App is debugged in WSL, it says LibHostInvalidArgs (0x80008092). Even while running in the Docker Container also
Same error occurs.


This is the Source code.
NativeHost.7z.gz
Projects are like this.
( NativeHost --- Native .So (Loads host fxr)
(Managed Assembly--- .NetCore Assembly to be loaded)
(NetProject--- .NetCore App Which loads NativeHost)
(ASPNetProject---ASP .NetCore App which loads NativeHost)
To reproduce the issue you can run the NetProject from Linux terminal NativeHost/NetProject/NetProject/NetProject/bin/Debug/net5.0$./NetProject
Please let us know your suggestion on this.