Microsoft.Bcl.AsyncInterfaces 当 运行 由 Visual Studio 安装项目安装的应用程序时出现错误(在 CSVHelper 方法中)

Microsoft.Bcl.AsyncInterfaces error (in CSVHelper method) when running the application installed by Visual Studio Setup project

我有一个 WPF 应用程序,它使用 CSVHelper 读取 CSV 文件,我是使用 NuGet 安装的。这是项目、系统等版本信息。

Microsoft Windows 7 Professional Version 6.1.7601 Service Pack 1 Build 7601

Microsoft Visual Studio Community 2019 Version 16.4.5

NuGet Package Manager 5.4.0

WPF Project Target Framework: .NET Framework 4.7.2

CSVHelper Version: 15.0.5

CSV reader 方法很简单;读取文件并将其放入列表中。没有什么花哨。我将 link 整个项目放在底部,如果您愿意,可以下载并试用。

当我 运行 在 ReleaseDebug 构建中生成的可执行文件时,它们工作正常。他们读取文件,将内容放入列表中,然后显示在 DataGrid 上就好了。下一步,我创建了一个标准 Visual Studio Setup 项目,并创建了一个 msi 安装程序,我用它在我的 PC 上安装应用程序。

但是,当我 运行 该可执行文件(位于我的 Program Files 目录中)时,应用程序抛出异常。这是异常消息和堆栈跟踪。

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
   at ReadCSVTest.MainWindow.ReadPeopleList(String path, List`1& people, String& msg)
   at ReadCSVTest.MainWindow..ctor()

由于错误提示无法加载程序集 Microsoft.Bcl.AsyncInterfaces,我从 NuGet 添加了它并再次 运行 所有内容,但我仍然收到错误。这里有什么问题? Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. 是什么意思?为什么只有当我 运行 安装项目安装的可执行文件时才会出现此异常?

请从 HERE 下载整个项目。

只是为了以后有人遇到同样的问题;正如 Jones 在评论中所建议的那样,将两个库中的每一个降级到以下版本为我解决了这个问题。

CsvHelper ==> 12.3.2

Microsoft.Bcl.AsyncInterfaces ==> 1.0.0