ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

在.net core 3.1项目中使用Sqlite

2021-11-12 17:05:36  阅读:880  来源: 互联网

标签:core Sqlite win 3.1 dllSystem linux Data native


由于项目需要使用Sqlite, 所以安装了一些Sqlite库。

刚开始用的是 Microsoft.Data.Sqlite.Core 6.0.0 ,但在new SqliteConnection 时抛出异常。
Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.GetFolderPath(String propertyName)
   at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.get_LocalFolderPath()
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   at Microsoft.Data.Sqlite.SqliteConnection..cctor()

 

不知道怎么解决,google了一下有人说用旧版没问题。于是,换成了上一个版本:5.0.12

//使用 Microsoft.Data.Sqlite.Core 5.0.12,在new 的时候不异常,但open()时异常:
System.Exception: 'You need to call SQLitePCL.raw.SetProvider().  If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().'
还缺了个库,再安装 SQLitePCLRaw.bundle_e_sqlite3 就好了,问题解决。

 

==========================================================================
另外,记得五年前,直接使用C编译的sqlite3.dll, 外加一个C#接口层,只需要两个dll.
现在使用这些包,硬盘就非常遭罪了,随便都超过3个dll!

//microsoft:  SqliteConnection
Microsoft.Data.Sqlite.dll
SQLitePCLRaw.batteries_v2.dll
SQLitePCLRaw.core.dll
SQLitePCLRaw.provider.e_sqlite3.dll
runtimes目录
    ├─alpine-x64
    │  └─native
    ├─linux-arm
    │  └─native
    ├─linux-arm64
    │  └─native
    ├─linux-armel
    │  └─native
    ├─linux-mips64
    │  └─native
    ├─linux-musl-x64
    │  └─native
    ├─linux-s390x
    │  └─native
    ├─linux-x64
    │  └─native
    ├─linux-x86
    │  └─native
    ├─osx-arm64
    │  └─native
    ├─osx-x64
    │  └─native
    ├─win-arm
    │  └─native
    ├─win-arm64
    │  └─native
    ├─win-x64
    │  └─native
    └─win-x86
        └─native


//官方:      SQLiteConnection
//官方依赖:
EntityFramework.dll
EntityFramework.SqlServer.dll
Microsoft.Win32.SystemEvents.dll
System.CodeDom.dll
System.Configuration.ConfigurationManager.dll
System.Data.SqlClient.dll
System.Data.SQLite.dll
System.Data.SQLite.EF6.dll
System.Drawing.Common.dll
System.Security.Cryptography.ProtectedData.dll
System.Security.Permissions.dll
System.Windows.Extensions.dll

runtimes目录
├─linux-x64
│  └─native
├─osx-x64
│  └─native
├─unix
│  └─lib
│      ├─netcoreapp2.1
│      └─netcoreapp3.0
├─win
│  └─lib
│      ├─netcoreapp2.1
│      ├─netcoreapp3.0
│      └─netstandard2.0
├─win-arm64
│  └─native
├─win-x64
│  └─native
└─win-x86
    └─native

 

标签:core,Sqlite,win,3.1,dllSystem,linux,Data,native
来源: https://www.cnblogs.com/wsk3q/p/15545458.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有