SQLite + SpatiaLite 问题
我正在尝试使用 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();
}
...
从此链接我得到的印象应该是工作。
提前致谢
I'm trying to access a SpatiaLite from C# using System.Data.SQLite provider. When I try to load the SpatiaLite extension, I always get the
System.Data.SQLite.SQLiteException: SQLite error
The specified module could not be found.
error, even though the spatialite's dll has been copied to the bin directory. I even tried specifying the absolute path to the dll, but to no avail.
Here's the code:
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();
}
...
From this link I get the impression this should work.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
多亏了 sqlite3.exe 命令行工具,我发现运行它还需要一些额外的 DLL:
您可以找到这些在SpatiaLite 的下载页面上。只需将它们复制到 bin 目录即可。
更新:需要一个额外的 dll 是libiconv2.dll
Well thanks to sqlite3.exe command line tool, I've found out that there are some additional DLLs needed for this to run:
You can find these on SpatiaLite's download page. Just copy them to the bin directory.
UPDATE: one additional dll needed is libiconv2.dll
我在Java中遇到了完全相同的问题。我为所有依赖的 DLL 调用了 System.load(),一切都运行得非常顺利!
I had the exact same problem in Java. I called System.load() for all the dependent DLLs and everything worked like a champ!