SQLite Forum

Loading bundled extensions in dotnet on linux
Hi everybody,

I'm trying to use the `json1` extension in C# (dotnet core), in an application that should support both Linux and Windows.

A very dumb sample could be:

public static void Main(string[] args)
    using (var connection = new SQLiteConnection(new SQLiteConnectionStringBuilder {
        DataSource = ":memory:",
    }.ConnectionString)) {
        connection.LoadExtension("SQLite.Interop.dll", "sqlite3_json_init");
        using (var command = new SQLiteCommand("SELECT json('[ 1,23,3   , 4]')", connection))
        using (var reader = command.ExecuteReader())
            while (reader.Read())
                for (int i = 0; i < reader.FieldCount; i++) {
                    Console.Write("{0}: {1}, ", reader.GetName(i), reader.GetValue(i));

Which works on Windows, but throws on Linux:

Unhandled exception. code = Error (1), message = System.Data.SQLite.SQLiteException (0x800007BF): SQL logic error
SQLite.Interop.dll.so: cannot open shared object file: No such file or directory
   at System.Data.SQLite.SQLite3.LoadExtension(String fileName, String procName)
   at System.Data.SQLite.SQLiteConnection.LoadExtension(String fileName, String procName)
   at test_api.Program.Main(String[] args) in <path>/Program.cs:line 33
   at test_api.Program.<Main>(String[] args)

The problem seems clear, but I don't have any idea on how to solve it without hardcoding paths/switching at runtime (or compile-time) on the OS/Architecture, which sounds like a very bad idea to me.

Thank you,

Marco Manino