DEV Community

Discussion on: Building a Better Library Loader in C# - Part 3

Collapse
 
deafman1983 profile image
DeafMan1983

Hello I found wrong ".dll" under Unix:

string library = "path/to/custom/sqlite3.dll";
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
IntPtr libraryHandle = isWindows ?
WinLoader.LoadLibrary(library) :
UnixLoader.Open(library, 1);

Replace with:
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
IntPtr libraryHandle = isWindows ?
WinLoader.LoadLibrary("path/to/custom/sqlite3.dll") :
UnixLoader.Open("path/to/custom/sqlite3.so", 1);

Because you use only *.dll o_O
If you use dynamic then it is file type as so for Linux/FreeBSD and dll for Windows

Thanks!

Collapse
 
thebuzzsaw profile image
Kelly Brown

For the sake of simplicity, I've actually compiled my native libs to have a .dll extension even under Linux. Then my loader code can be the same for all platforms. I would never name a Linux library .dll if it were to become a system/shared library (as in /usr/lib), but if it's bundled with my own code for private usage, I don't see a problem.