我在一个解决方案中有两个项目。一个是安装了三个nuget包的类库:HtmlAgilityPack,Microsoft.Syndication和IrcDotNet。另一个是启动项目,一个只安装了一个Nuget Package的控制台应用程序项目,Microsoft.Syndication。该项目还依赖于类库。当我运行启动项目时,我得到一个例外,其中包含以下细节。
发生System.IO.FileNotFoundException HResult = 0x80070002消息=无法加载文件或程序集' System.Runtime, Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'要么 其中一个依赖项。系统找不到指定的文件 Source = StackTrace:at AlexiConsole.Program.Main(String [] args)in c:\ Users \ myself \ documents \ visual studio 2017 \ Projects \ Alexi \ AlexiConsole \ Program.cs:第21行
内部异常1:FileNotFoundException:无法加载文件或 assembly' System.Runtime,Version = 4.0.20.0,Culture = neutral, 公钥= b03f5f7f11d50a3a'或其中一个依赖项。该 系统找不到指定的文件。
我不知道为什么。我已经在两个项目的app.config中都有绑定重定向,用于将版本0.0.0.0-4.1.0.0重定向到4.1.0.0。
两个项目都以.NET 4.7为目标。
答案 0 :(得分:3)
我面临同样的问题,我的问题是
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.
要解决此问题,请在Web.config文件和重建应用程序中包含<dependentAssembly></dependentAssembly>
的注释程序集culture="neutral"
。我的应用程序正常运行并解决问题。
答案 1 :(得分:2)
我自己解决了这个问题。我重新创建了两个项目,目标是.NET 4.7,问题得到了解决。
问题可能是我最初针对早期版本的.NET,然后更改了版本。但我不确定。
答案 2 :(得分:1)
我也遇到过同样的问题。只需按照以下步骤解决您的问题
Manage NuGet Packages for Solution
Installed
标签中搜索System.Runtime
System.Runtime
到以前的版本,然后再次升级它现在应该可以使用。
答案 3 :(得分:0)
就我而言,当我进行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.
删除这些绑定:
<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>