I'm looking for a solution for dynamically change the dll path when using DLLImport attribute under Linux. I have an if statement for checking the current OS (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)), and if the application runs on windows than I'm using the SetDllDirectory method from kernel32.dll to dynamically add a folder to the dll search path.
For Windows I have two different dlls to load based on some runtime decision. they will be located at Environment.CurrentDirectory + Drivers/Win/1/ and Environment.CurrentDirectory + Drivers/Win/2/.
For Linux, the .so will be located at Environment.CurrentDirectory + Drivers/Linux/
The dlls and so files have the exact same interface and name.
Is there an equivalent solution like SetDllDirectory for Linux under .NET 5?
Thanks