无法加载文件或程序集'System.Data.SQLite,版本= 1.0.109.0-为什么当我引用1.0.109.1时会搜索版本1.0.109.0 [英] Could not load file or assembly 'System.Data.SQLite, Version=1.0.109.0 - Why does it search for version 1.0.109.0 when I have referenced 1.0.109.1

查看:46
本文介绍了无法加载文件或程序集'System.Data.SQLite,版本= 1.0.109.0-为什么当我引用1.0.109.1时会搜索版本1.0.109.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了新的 ASP.NET Core Web应用程序,并使用了 ASP.NET Core 2.1 跨平台框架.

I have created new ASP.NET Core Web Application and used ASP.NET Core 2.1 cross platform framework.

接下来,我使用 Nuget Manager 添加了 System.Data.SQLite.Core .这是x86和x64以及ADO.NET提供程序的官方SQLite数据库引擎.

Next, I added System.Data.SQLite.Core using Nuget manager. It's the official SQLite database engine for both x86 and x64 along with the ADO.NET provider.

我的主要方法

    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
        SQLiteConnection con = new SQLiteConnection("abc");
    }

当我运行该应用程序时,它将尝试搜索 1.0.109.0 ,而不是已安装的 1.0.109.1 版本.

When I run the application, it's trying to search for 1.0.109.0 instead of installed 1.0.109.1 version.

所以最终会像预期的那样抛出异常以下的情况

So end up throwing below exception as expected

System.IO.FileNotFoundExceptionHResult = 0x80070002消息=无法加载文件或程序集'System.Data.SQLite,Version = 1.0.109.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'.该系统找不到指定的文件.来源=

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'. The system cannot find the file specified. Source=

那么,为什么它要搜索错误的版本?

So, why it's searching for wrong version?

屏幕截图仅供参考

我的解决方案平台是任何CPU",并且我在x64的x64 Windows 7上运行

My Solution platform is "Any CPU" and I'm running on a x64 Windows 7 on an x64

奇怪

当我在 SQLiteConnection 类上执行 F12 时,它将转到

When I do F12 on SQLiteConnection class, it goes to

我的.csproj文件已获得

My .csproj file conent

 <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>

推荐答案

我遇到了完全相同的问题.最终为我工作的是:

I had this exact same issue. What ended up working for me was:

  1. 在Windows资源管理器中,导航到%UserProfile%\.nuget \ packages
  2. 删除 system.data.sqlite.core system.data.sqlite.core
  3. 的目录
  4. 在您的 .csproj 中,将sqlite包引用更改为

  1. In Windows Explorer, navigate to %UserProfile%\.nuget\packages
  2. Delete the directories for system.data.sqlite.core and system.data.sqlite.core
  3. In your .csproj, change your sqlite package reference to

`<PackageReference Include="System.Data.SQLite.Core" Version="1.0.109.0"/>`

  • 重建项目以恢复软件包
  • 这篇关于无法加载文件或程序集'System.Data.SQLite,版本= 1.0.109.0-为什么当我引用1.0.109.1时会搜索版本1.0.109.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆