我已经创建了新的ASP.NET Core Web Application
并使用ASP.NET Core 2.1
跨平台框架。
接下来,我添加了System.Data.SQLite.Core
using Nuget manager
。它是适用于 x86 和 x64 的官方 SQLite 数据库引擎以及 ADO.NET 提供程序。
我的主要方法
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
SQLiteConnection con = new SQLiteConnection("abc");
}
当我运行该应用程序时,它会尝试搜索1.0.109.0而不是安装的1.0.109.1
版本。
所以最终会按预期抛出以下异常
System.IO.FileNotFoundException
H结果=0x80070002
消息=无法加载文件或程序集“System.Data.SQLite,版本=1.0.109.0,文化=中性,PublicKeyToken=db937bc2d44ff139”。该系统找不到指定的文件。
来源=
那么,为什么它会搜索错误的版本呢?
截图供参考
我的解决方案平台是“任何 CPU”,我在 x64 Windows 7 上运行
Strange
当我做F12 on SQLiteConnection
类,它去
我的 .csproj 文件内容
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.109.1" />
</ItemGroup>
我有这个完全相同的问题。最终为我工作的是:
- 在 Windows 资源管理器中,导航至
%UserProfile%\.nuget\packages
- 删除目录
system.data.sqlite.core
and system.data.sqlite.core
-
In your .csproj
,将您的 sqlite 包引用更改为
`<PackageReference Include="System.Data.SQLite.Core" Version="1.0.109.0"/>`
- 重建项目以恢复包
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)