繁体   English   中英

获得适用于x64 c#的SpatiaLite + SQLite系统

[英]Getting a working SpatiaLite + SQLite system for x64 c#

我需要在x64窗口下创建和访问一个spacespaceite扩展的SQLite数据库。

我已经下载了System.Data.SQLite的最新版本1.0.92.0,名为sqlite-netFx45-static-binary-bundle-x64-2012-1.0.92.0.zip 它是从我的Visual Studio(2012)项目中引用的,它似乎可以正常工作。

我也有最新的预编译x64 spatiaLite版本4.1.1,称为spacespaceite-4.1.1-DLL-win-amd64.zip。来自spacespaceite的所有dll都位于执行目录中。

当我尝试加载扩展程序时:

using (var conn = new SQLiteConnection("Data Source=\"" + _sqLiteFullName + "\""))
{
    conn.Open();
    conn.EnableExtensions(true);
    conn.LoadExtension("libspatialite-4.dll");
    ...
}

我在LoadExtension()行上收到一个AccessViolationException (试图读取受保护的内存。这通常表明其他内存已损坏)。

我注意到当使用PE Deconstructor (确定dll / exe的bitnewss的软件)查看时,它说我的System.Data.SQLite.dll副本(来自x64软件包)实际上是32位。 那是问题吗?

我该如何补救?

其他人如何在x64上使用spatiaLite?

实际上,问题可能出在我自己花了一个星期试图解决相同问题但没有成功的autumnite -4.dll中 好像在spacespaceite-4.dll中有问题(我是说这是从gaia-sins(官方spacesite网站)下载的),您可以尝试从源代码构建Spatialite(例如噩梦(:)或尝试寻找另一个) .dll的构建第二个选择帮助了我,顺便说一句,使用Spatialite扩展名需要几个.dll:

  1. libsqlite3-0.dll
  2. libgeos-3-0-2.dll
  3. libgeos-c-1.dll
  4. libiconv2.dll
  5. libproj-0.dll
  6. libvirtualtext-2.dll
  7. libspatialite-2.dll <----- Spatialite v.2完全适合我的项目。 如我所讲,如果您需要v.4,则可以尝试构建它或寻找另一个构建。 希望这可以帮助

站点下载mod_spatialite,选择mod_spatialite-4.2.0-win-amd64.7z。 解压缩所有dll并将其复制到程序的bin文件夹中。

样例代码:

//SELECT load_extension("mod_spatialite") // doesn't need the '.dll' suffix.

using (var cnn = new SQLiteConnection(connStr))
            {
                //connStr = "FullUri=file::memory:?cache=shared;Pooling=True;Max Pool Size=200;";


                cnn.Open();
                //cnn.EnableExtensions(true);

                using (SQLiteCommand mycommand = new SQLiteCommand("SELECT load_extension(\"mod_spatialite\")", cnn))
                {
                    mycommand.ExecuteNonQuery();
                }

在这里查看此Google网上论坛讨论:

https://groups.google.com/forum/#!topic/spatialite-users/u2QZpQL_6ek

最新的解决方案是Dominik提供的:

我刚刚发现,在http://blog.jrg.com.br/2016/04/25/Fixing-spatialite-loading-problem/中描述的黑客攻击仅适用于mingw64第二最新版本的dll。
来自http://netassist.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_x86_64-linux_20131228.tar的 mingw-w64-bin_x86_64-linux_20131228.tar.bz2 。 bz2
在sourcefourge http://sourceforge.net/projects/mingw-w64/files/latest/download上使用最新版本进行的任何尝试均在我的系统上失败。

但是,我可以肯定地确认,可以使用以下命令加载mod_spatialite

MyConnection.LoadExtension("mod_spatilite");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM