-->

SQLite的+ SpatiaLite问题(SQLite + SpatiaLite problems

2019-08-17 20:30发布

我试图访问使用System.Data.SQLite提供C#中的SpatiaLite。 当我尝试加载SpatiaLite扩展,我总是得到

System.Data.SQLite.SQLiteException: SQLite error
The specified module could not be found.

错误,即使spatialite的DLL已经被复制到bin目录。 我甚至尝试指定到DLL的绝对路径,但无济于事。

下面的代码:

string connectionString = @"Data Source=D:\MyStuff\projects\OsmUtils\trunk\Data\Samples\DB\osm.sqlite";
using (SQLiteConnection connection = new SQLiteConnection (connectionString))
{
    connection.Open();

    using (SQLiteCommand command = connection.CreateCommand())
    {
        command.CommandText = @"SELECT load_extension('libspatialite-1.dll');";
        command.ExecuteScalar();
    }
    ...

从这个链接给我的感觉这应该工作。

提前致谢

Answer 1:

好感谢sqlite3.exe命令行工具,我发现了,有需要它来运行一些额外的DLL文件:

  • libproj-0.dll
  • libgeos-3-1-1.dll
  • libgeos_c-1.DLL

您可以找到这些SpatiaLite的下载页面 。 把它们复制到bin目录。

更新:需要一个额外的DLL是libiconv2.dll



Answer 2:

我在Java中有完全相同的问题。 我叫System.load()为所有相关的DLL和一切工作就像一个冠军!

  • libproj-0.dll
  • libgeos-3-1-1.dll
  • libgeos_c-1.DLL
  • libiconv2.dll
  • libcharset1.dll


文章来源: SQLite + SpatiaLite problems