获取工作SpatiaLite + SQLite系统x64 c# [英] Getting a working SpatiaLite + SQLite system for x64 c#

查看:878
本文介绍了获取工作SpatiaLite + SQLite系统x64 c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在x64 windows下创建和访问一个空间扩展的SQLite数据库。



我已经下载了最新版本1.0.92.0,名为 sqlite-netFx45-static-binary-bundle-x64-2012-1.0.92.0.zip of System.Data.SQLite 。它是从我的Visual Studio(2012)项目引用,并且似乎自己工作很好。



我也有最新的预编译x64 spatiaLite 版本4.1.1名为spatialite-4.1.1-DLL-win-amd64.zip $ b



当我尝试加载扩展时:

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

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

我注意到当使用 PE解构函数(确定bitnewss的dll / exe),它说,我的System.Data.SQLite.dll(从x64包)的副本实际上是32位。这是问题吗?



如何解决这个问题?



如何让其他任何人得到spatiaLite工作x64 ?

解决方案

site ,选择mod_spatialite-4.2.0-win-amd64.7z。解压缩并复制所有dll到你的程序的bin文件夹。



示例代码:
SELECT load_extension(mod_spatialite)//不需要' .dll'后缀。

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


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

使用(SQLiteCommand mycommand = new SQLiteCommand(SELECT load_extension(\mod_spatialite \),cnn))
{
mycommand.ExecuteNonQuery
}


I need to create and access a spatialite-extended SQLite database under x64 windows.

I have downloaded the latest version 1.0.92.0 called sqlite-netFx45-static-binary-bundle-x64-2012-1.0.92.0.zip of System.Data.SQLite. It is referenced from my Visual Studio (2012) project, and seems to work just fine by itself.

I also have the latest precompiled x64 spatiaLite version 4.1.1 called spatialite-4.1.1-DLL-win-amd64.zip All the dlls from spatialite are present in the executing directory.

When I try to load the extension:

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

I get an AccessViolationException (Attempted to read protected memory. This is often an indication that other memory is corrupt) on the LoadExtension() line.

I notice when looked at with PE Deconstructor (software that determines the bitnewss of dll/exe), it says that my copy of System.Data.SQLite.dll (from the x64 package) is actually 32bits. Is that the problem?

How to I remedy this?

How has anyone else got spatiaLite working on x64?

解决方案

download mod_spatialite from the site, choose mod_spatialite-4.2.0-win-amd64.7z. unzip and copy all dll to the bin folder of your program.

sample code: 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();
                }

这篇关于获取工作SpatiaLite + SQLite系统x64 c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆