Problem with x64 bit mod_spatialite

580 views
Skip to first unread message

Steve Paplanus

unread,
Oct 28, 2015, 1:12:15 PM10/28/15
to SpatiaLite Users
I am new to Spatialite.   I created a c# application with mod_spatialite-4.3.0a-win-amd64 and sqlite-dll-win64-x6-3090100.   I created a simple application set to an x64 target and trying both the 4.5 and 4.6 framework separately that was going to load the mod_spatialite extension, and then read a spatialite table into a dataset.     

Everytime I attempt to run it, I get an error :

An unhandled exception of type 'System.Data.SQLite.SQLiteException' occurred in System.Data.SQLite.dll

Additional information: SQL logic error or missing database

%1 is not a valid Win32 application.

when I try to execute the sqlite command "select load_extension('mod_spatialite')".   This happens when i execute the SQLite.Data.SQLite.SQLiteCommmand.  If I do it outside the program, the program exits immediately.   If I use the 32-bit equivalent for the mod_spatialite or sqlite, and set the program to x86, I get no error.  

I would really like to use the x64 version, but have had no luck in a VS 2013 or VS 2015.   

Steve

Pac

unread,
Oct 29, 2015, 7:22:40 AM10/29/15
to SpatiaLite Users
Hi Steve,

Assuming your application is executed in a x64 environment, please check the following:
  1. Your application is compiled as x64 or AnyCPU but executed in a x64 environment.
  2. System.Data.SQLite is x64 or AnyCPU. For instance, I use sometimes System.Data.SQLite.Core (MSIL) NuGet package.
  3. If your application uses SQLite.Interop.dll (which means System.Data.SQLite is not a mixed mode version), its platform must be x64. For instance, I use sometimes System.Data.SQLite.Core NuGet package which includes it.
  4. Your application loads mod_spatialite for x64. For instance, I use sometimes SpatiaLiteSharp NuGet package which also assures that your own mod_spatialite (and its related DLLs) is executed, not a copy found elsewhere in your PATH environement variable.
Apart of that, System.Data.SQLite.SQLiteConnection class has a handy method named LoadExtension wich eases SpatiaLite's loading because there's no need for a SQLiteCommmand to execute.

Regards,
Paco.
Reply all
Reply to author
Forward
0 new messages