我正在尝试在设置连接时加载新的json1扩展,但我一直收到此错误:
SQL逻辑错误或缺少数据库找不到
指定的过程.
这是我的代码:
SQLiteConnection connection = (SQLiteConnection)session.Connection;
connection.EnableExtensions(true);
Assembly assembly = Assembly.Load("System.Data.SQLite");
connection.LoadExtension(assembly.Location, "sqlite3_json_init");
Run Code Online (Sandbox Code Playgroud)
我正在使用NHibernate,所以我只是在执行任何逻辑之前从会话中获取连接.
有什么我做错了吗?我也尝试加载SQLite.Interop.dll,然后调用该sqlite3_json_init方法,但仍然无法正常工作.
我做了这个,它似乎仍然没有工作:
SQLiteConnection connection = (SQLiteConnection)session.Connection;
connection.EnableExtensions(true);
string path = "F:\\GitHub\\ExampleProj\\lib\\sqlite\\SQLite.Interop.dll";
if (File.Exists(path))
{
connection.LoadExtension(path,
"sqlite3_json_init");
}
Run Code Online (Sandbox Code Playgroud)
从SQLite.Interop.dll加载扩展是正确的方法.所以你应该能够做到以下几点:
connection.EnableExtensions(true);
connection.LoadExtension(@"full\path\to\SQLite.Interop.dll", "sqlite3_json_init");
Run Code Online (Sandbox Code Playgroud)
我已经测试了它并且它正在工作,所以如果你仍有问题,你可能需要说明你是如何获得互操作文件的路径的.出于调试目的,可能在LoadExtension之前添加一个断言,以确保您尝试加载的互操作文件实际存在于您认为的位置.
还要确保你正在加载正确的版本(x86与x64.)如果你尝试了错误的版本,你会得到,"找不到指定的模块." 在LoadExtension调用,即使它实际上在那里.
实际上,您似乎不需要输入互操作文件的完整路径。显然,它识别您正在使用的处理器架构,并根据该架构在 bin 文件夹中找到 SQLite.Interop.dll 文件(bin/x64/ SQLite.Interop.dll)。我只需给它互操作文件的名称,它就可以工作:
SQLiteConnection connection = (SQLiteConnection)sender;
connection.EnableExtensions(true);
connection.LoadExtension("SQLite.Interop.dll", "sqlite3_json_init");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2349 次 |
| 最近记录: |