I'm having some troubles with loading the mod_spatialite extension in sqlite in an ASP.NET Core 3.1 application. When I run the code below I get the following error: "SQL logic error The specified module could not be found."
string dbFile = "D:\\Temp\\spatialtest.db";
string connectString = $"Data Source={dbFile};Version=3;";
SQLiteConnection connection = new SQLiteConnection(connectString);
connection.Open();
connection.EnableExtensions(true);
connection.LoadExtension("mod_spatialite");
I reference the System.Data.Sqlite(https://www.nuget.org/packages/System.Data.SQLite/1.0.113.1) package from NuGet. The packages I use for loading in spatialite are found here http://www.gaia-gis.it/gaia-sins/. I tried the packages from the current stable 4.3.0a and the new 5.0.0-RC1, both the amd64 and x86 binaries.
The weird thing is that when I copy the code to an .NET Core Console application or to an .NET Core Class Library(CL) and then reference the CL from the console application it does work.
I don't get why it does work in an Console application and not in an ASP.NET application. Am I missing something? Any help is greatly appreciated!
EDIT: Added test project to Github: https://github.com/RogierB/SQLiteSpatialiteTest