繁体   English   中英

sqlite.net PCL抛出TypeInitalizationException

[英]sqlite.net PCL throws TypeInitalizationException

我们从sqlite-net更改为sqlite.net PCL版。 我们的项目与旧项目合作得很好 - 在PCL版本中,我们现在必须通过使用明确声明我们的平台。

var conn = new SQLiteConnection(new SQLitePlatformWin32(),  Path.Combine(folderPath, dbName));

但是现在,当我打电话给这一行时,我们得到一个

SQLite.Net.Platform.Win32.dll中出现'System.TypeInitializationException'类型的第一次机会异常

附加信息:“SQLite.Net.Platform.Win32.SQLiteApiWin32Internal”的类型初始化程序引发了异常。

内在的例外告诉我们

{“无法加载本机sqlite库”}

堆栈跟踪:

在SQLite.Net.Platform.Win32.SQLiteApiWin32Internal.sqlite3_open_v2(Byte [] filename,IntPtr&db,Int32标志,IntPtr zvfs)

在SQLite.Net.Platform.Win32.SQLiteApiWin32.Open(Byte [] filename,IDbHandle&db,Int32 flags,IntPtr zvfs)

在SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform,String databasePath,SQLiteOpenFlags openFlags,Boolean storeDateTimeAsTicks,IBlobSerializer serializer,IDictionary 2 tableMappings, IDictionary 2 extraTypeMappings,IContractResolver resolver)

在SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform,String databasePath,Boolean storeDateTimeAsTicks,IBlobSerializer serializer,IDictionary 2 tableMappings, IDictionary 2 extraTypeMappings,IContractResolver resolver)

但是,sqlite3.dll位于应用程序文件夹中,它实际上可以使用unforked版本。 我玩了编译x86和x64,并为Win32下载了最新的sqlite3.dll,但都没有成功。 我们缺少什么?

我在测试项目中遇到了同样的问题。 通过为SQLitePlatformWin32添加包http://www.nuget.org/packages/System.Data.SQLite.Core解决了这个问题。

虽然未在实际版本中列为依赖项,但它是在平台的nuget包之前的一个( http://www.nuget.org/packages/SQLite.Net.Platform.Win32/

另外:如果使用SQLitePlatformGeneric,应将sqlite3.dll的副本放在输出目录中。

暂无
暂无

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

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