簡體   English   中英

無法加載文件或程序集System.Runtime

[英]Cannot load file or assembly System.Runtime

一個解決方案中有兩個項目。 一個類庫具有安裝的三個nuget包:HtmlAgilityPack,Microsoft.Syndication和IrcDotNet。 另一個是啟動項目,這是一個僅安裝了一個Nuget軟件包的控制台應用程序項目,即Microsoft.Syndication。 該項目還依賴於類庫。 運行啟動項目時,出現以下異常。

發生System.IO.FileNotFoundException HResult = 0x80070002消息=無法加載文件或程序集'System.Runtime,版本= 4.1.0.0,區域性=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依賴項之一。 該系統找不到指定的文件。
Source = StackTrace:在c:\\ Users \\ myself \\ documents \\ visual studio 2017 \\ Projects \\ Alexi \\ AlexiConsole \\ Program.cs:line 21的AlexiConsole.Program.Main(String [] args)

內部異常1:FileNotFoundException:無法加載文件或程序集'System.Runtime,版本= 4.0.20.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依賴項之一。 該系統找不到指定的文件。

我不知道為什么 我已經在兩個項目的app.config中具有綁定重定向,用於將版本0.0.0.0-4.1.0.0重定向到4.1.0.0。

這兩個項目的目標都是.NET 4.7。

我遇到同樣的問題,我的問題是

 System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 

若要解決此問題,請注釋程序集<dependentAssembly></dependentAssembly> ,該程序集在Web.config文件和Rebuild Application中包含culture="neutral" 我的應用程序可以正常運行,並且可以解決問題。

我自己解決了這個問題。 我重新創建了兩個針對.NET 4.7的項目,此問題已解決。

可能的問題是,我最初的目標是.NET的早期版本,然后又更改了版本。 但我不確定。

我曾經遇到過同樣的問題。 只需按照以下步驟解決您的問題

  • 右鍵單擊您的解決方案,然后選擇“ Manage NuGet Packages for Solution
  • 在“ Installed選項卡中,搜索“ System.Runtime
  • 現在您可以看到已在哪個項目中安裝了庫
  • 選擇合適的項目並將System.Runtime 降級到以前的版本並再次升級
  • 清理並重建您的解決方案
  • 運行項目

現在應該可以使用了。

就我而言,當我進行Grpc調用時,我的WPF可執行文件開始崩潰。 事實證明,項目的app.config文件包含IDK留下的一些程序集綁定(VS 2019 16.3更新?NuGet更新?)。 刪除它們后,它又可以工作了。

例外

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Source=System.Memory StackTrace: at System.SpanHelpers.PerTypeValues'1.MeasureArrayAdjustment() at System.SpanHelpers.PerTypeValues'1..cctor()

Inner Exception 1: FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.


App.config

刪除這些綁定:

<dependentAssembly> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly>

暫無
暫無

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

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