问题描述
仅当我发布.Net 4.6.2控制台应用程序并将其安装在远程Win 2012r2上时,才会弹出此错误.
This error only pops up when I publish my .Net 4.6.2 console application and install it on a remote Win 2012r2.
很不幸,我安装了荷兰语语言包.但它说:未处理的异常.找不到文件或程序集system.net.http或依赖项之一.
Unfortunately I have the dutch lang pack installed. But it says: unhandled exception. Can't find file or assembly system.net.http or one of the dependencies.
我有一个带有nuget System.Net.Http 4.3.2
(最新)的控制台应用程序,但这似乎与Signalr.Client
有关,这在我的Class Lib(.Net 4.6.2)项目中.有一个Signalr.Client
nuget 2.2.2,它依赖于 Microsoft .Net.Http,因此在该类库中我没有对System.Net.Http
的nuget/ref.由于这个错误,我为System.Net.Http
4.3.2添加了nuget,但是并没有解决它.错误仍然相同.我什至无法将4.3.2降级到4.1.1.1,因为只有4.1.1
I have a console app with the nuget System.Net.Http 4.3.2
(latest) but this seems to happen with something Signalr.Client
related which is in my Class Lib (.Net 4.6.2) project. There is a Signalr.Client
nuget 2.2.2 which depends on Microsoft.Net.Http so I did not had a nuget/ref to System.Net.Http
in that class lib. Because of this error, I added the nuget for System.Net.Http
4.3.2 but that did not solve it. The error is still the same. I can't even downgrade 4.3.2 to 4.1.1.1 because there is only 4.1.1
当我降级到4.1.1时,错误仍然相同,并且已安装System.Diagnostics.DiagnosticSource.4.0.0
.因此,无论我尝试什么.我一直在生产中收到此错误.在我的机器上工作...我已经阅读了有关在解决方案资源管理器中的引用"节点中删除默认引用的内容. 但这并不能解决问题.
When I downgraded to 4.1.1 the error is still the same and System.Diagnostics.DiagnosticSource.4.0.0
is installed. So no matter what I try. I keep getting this error in production. Works on my machine...I have read something about removing the default ref in the references node in the solution explorer. Why I can not use System.Net.Http package in a solution with System.Net.Http reference?But that did not solve it.
推荐答案
必须在控制台应用程序项目和类lib项目的app.config中对此段进行注释
Had to comment out this piece in app.config of both the console app project and the class lib project
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!--<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" />
</dependentAssembly>-->
</assemblyBinding>
</runtime>
</configuration>
它以某种方式自动添加到两个app.config
文件中.我知道我自己没有添加这些行.
It was somehow auto added to both app.config
files. I know that I did not add those lines myself.
这篇关于生产System.Net.Http 4.1.1.1中的异常处理FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!