簡體   English   中英

運行 Visual Studio 安裝項目安裝的應用程序時出現 Microsoft.Bcl.AsyncInterfaces 錯誤(在 CSVHelper 方法中)

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

我有一個 WPF 應用程序,它使用我使用CSVHelper安裝的NuGet讀取 CSV 文件。 這是項目、系統等版本信息。

Microsoft Windows 7 專業版 6.1.7601 Service Pack 1 Build 7601

Microsoft Visual Studio 社區 2019 版本 16.4.5

NuGet Package 管理器 5.4.0

WPF 項目目標框架:.NET 框架4.7.2

CSVHelper 版本:15.0.5

CSV 閱讀器方法很簡單; 讀取文件並將其放入列表中。 沒有什么花哨。 我將在底部鏈接整個項目,以便您可以下載並嘗試一下。

當我運行在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. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. ? 為什么我只有在運行安裝項目安裝的可執行文件時才會出現這個異常?

請從這里下載整個項目。

就像將來任何人都會遇到同樣的問題一樣; 正如瓊斯在評論中建議的那樣,將兩個庫中的每一個降級到以下版本為我解決了這個問題。

CsvHelper ==> 12.3.2

Microsoft.Bcl.AsyncInterfaces ==> 1.0.0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM