[英]Microsoft.Bcl.AsyncInterfaces error (in CSVHelper method) when running the application installed by Visual Studio Setup project
I have a WPF application that reads a CSV file using CSVHelper
which I installed using NuGet
.我有一个 WPF 应用程序,它使用我使用
CSVHelper
安装的NuGet
读取 CSV 文件。 Here's the project, system, etc version info.这是项目、系统等版本信息。
Microsoft Windows 7 Professional Version 6.1.7601 Service Pack 1 Build 7601
Microsoft Windows 7 专业版 6.1.7601 Service Pack 1 Build 7601
Microsoft Visual Studio Community 2019 Version 16.4.5
Microsoft Visual Studio 社区 2019 版本 16.4.5
NuGet Package Manager 5.4.0
NuGet Package 管理器 5.4.0
WPF Project Target Framework: .NET Framework 4.7.2
WPF 项目目标框架:.NET 框架4.7.2
CSVHelper Version: 15.0.5
CSVHelper 版本:15.0.5
CSV reader method is straightforward; CSV 阅读器方法很简单; read a file and put it in a list.
读取文件并将其放入列表中。 Nothing fancy.
没有什么花哨。 I'll link the entire project at the bottom so you can download and try it out if you want.
我将在底部链接整个项目,以便您可以下载并尝试一下。
When I run the executable made in either Release
or Debug
builds, they work fine.当我运行在
Release
或Debug
版本中生成的可执行文件时,它们工作正常。 They read the file, put contents in a list, and display on a DataGrid
just fine.他们读取文件,将内容放入列表中,然后在
DataGrid
上显示就可以了。 As a next step, I created a standard Visual Studio Setup
project, and created an msi
installer, which I used to install the app in my PC.下一步,我创建了一个标准的
Visual Studio Setup
项目,并创建了一个msi
安装程序,用于在我的 PC 中安装应用程序。
When I run that executable (which is in my Program Files directory), however, the application throws an exception.但是,当我运行该可执行文件(位于我的 Program Files 目录中)时,应用程序会引发异常。 Here's the exception message and Stack Trace.
这是异常消息和堆栈跟踪。
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()
Since the error says couldn't load the assembly Microsoft.Bcl.AsyncInterfaces
, I added that from NuGet and ran everything again, and I still get the error.由于错误说无法加载程序集
Microsoft.Bcl.AsyncInterfaces
,我从 NuGet 添加了它并再次运行所有内容,但我仍然收到错误。 What's the problem here?这里有什么问题? What does it mean that
Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.
Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.
Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.
? ? And why do I only get this exception when I run the executable installed by the Setup project?
为什么我只有在运行安装项目安装的可执行文件时才会出现这个异常?
Just so anyone runs into the same issue in the future;就像将来任何人都会遇到同样的问题一样; as Jones suggested in the comments, downgrading each of the two libraries to following versions fixed the issue for me.
正如琼斯在评论中建议的那样,将两个库中的每一个降级到以下版本为我解决了这个问题。
CsvHelper ==> 12.3.2
And和
Microsoft.Bcl.AsyncInterfaces ==> 1.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.