简体   繁体   English

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

[英]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.当我运行在ReleaseDebug版本中生成的可执行文件时,它们工作正常。 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?为什么我只有在运行安装项目安装的可执行文件时才会出现这个异常?

Please download the entire project from HERE .请从这里下载整个项目。

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.

相关问题 如何在未安装Office 2010的计算机上安装带有MS Access数据库的Visual Studio 2010安装项目? - How to install visual studio 2010 setup project with MS Access database on a computer which is not having Office 2010 installed? 与安装项目一起安装的WPF应用程序崩溃 - WPF application installed with Setup project crashes Visual Studio 2012安装程序项目模板在哪里? - Where is Visual studio 2012 Setup project template? 发布的项目需要安装Visual Studio - Published project requires visual studio installed 在Visual Studio 2012中创建WPF安装程序项目 - Create WPF Setup project in visual studio 2012 在 Visual Studio 中重命名安装项目中的文件 - Renaming file in setup project in visual studio 如果安装了Visual Studio,WPF应用程序将不会关闭 - WPF application will not close if Visual Studio is installed 使用Visual Studio安装程序安装应用程序后无法访问.mdf文件 - Unable to access .mdf file after installing application using Visual Studio setup project Visual Studio 2010 安装项目 - 对现有安装的小更新 - Visual Studio 2010 Setup Project - Minor update to an existing installation 如何从Visual Studio 2012获取已安装应用程序的文件夹路径 - How to get folder path of Installed application, from Visual Studio 2012
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM