【问题标题】:Could not load file or assembly 'CsvHelper' (C#, VS2019, CSVHelper)无法加载文件或程序集“CsvHelper”(C#、VS2019、CSVHelper)
【发布时间】:2021-01-08 17:46:51
【问题描述】:

我有一个使用CSVHelper (v19.0.0) 的类库。我在 VS2019(版本 16.5.5;.NET 4.8.03752)中通过 Nuget 安装了CSVHelper,并且可以确认包在“应该”的位置(基于检查我的项目/依赖项/包/CSVHelper/properties,其中显示C:\Users\[my_name]\.nuget\packages\csvhelper\19.0.0)。 [编辑:我检查了我的 [解决方案名称].csproj 文件,发现其中包含 PackageReference Include="CsvHelper" Version="19.0.0"]

但是,当我尝试调用我的类库中的方法之一时,我收到如下所示的错误消息。

我在谷歌上搜索过这个问题,其他人在使用早期版本的 CSVHelper(例如https://github.com/JoshClose/CsvHelper/issues/944)时遇到了同样的问题,但他们的解决方案对我不起作用。我尝试过:1)清理和重建解决方案; 2) 删除 CSVHelper 然后通过 Nuget 重新安装;和 3) 从我的 C 驱动器上的 .nuget 文件夹中删除所有旧版本的 CSVHelper。问题继续出现。非常感谢您的帮助。

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'CsvHelper, Version=19.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823' or one of its dependencies. The system cannot find the file specified.
  

【问题讨论】:

    标签: c# visual-studio csvhelper


    【解决方案1】:

    我将回答我自己的问题而不是删除它,希望它对其他人有所帮助。

    我通过以下方式“修复”了这个问题:

    1. 手动将 CsvHelper.dll 复制到我的 bin\Debug\netstandard2.0 文件夹 项目
    2. 直接添加对该 dll 的引用
    3. 删除对 CsvHelper 的 Nuget 引用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      • 2010-10-01
      • 1970-01-01
      • 2014-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多