Unhandeld exception in production System.Net.Http 4.1.1.1 FileNotFoundException

删除回忆录丶 提交于 2019-12-13 08:59:04

问题


This error only pops up when I publish my .Net 4.6.2 console application and install it on a remote Win 2012r2.

Onverwerkte uitzondering: System.IO.FileNotFoundException: Kan bestand of assembly Sy stem.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of e en van de afhankelijkheden hiervan niet laden. Het systeem kan het opgegeven bestand niet vinden. ---> System.IO.FileNotFoundException: Kan bestand of assembly System.Net .Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of een van d e afhankelijkheden hiervan niet laden. Het systeem kan het opgegeven bestand niet vin den. --- Einde van intern uitzonderingsstackpad --- bij Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient.Initialize(IConnection connection) bij Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.GetNegotiationRespo nse(IHttpClient httpClient, IConnection connection, String connectionData) bij Microsoft.AspNet.SignalR.Client.Transports.AutoTransport.GetNegotiateResponse( IConnection connection, String connectionData) bij Microsoft.AspNet.SignalR.Client.Transports.AutoTransport.Negotiate(IConnection connection, String connectionData) bij Microsoft.AspNet.SignalR.Client.Connection.Negotiate(IClientTransport transpor t) bij Microsoft.AspNet.SignalR.Client.Connection.Start(IClientTransport transport) bij Microsoft.AspNet.SignalR.Client.Connection.Start() bij CasaCommon.HouseContext..ctor() bij ConsoleApp4.Program.GetOperator() bij ConsoleApp4.Program.Main(String[] args)

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.

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

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.


回答1:


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>

It was somehow auto added to both app.config files. I know that I did not add those lines myself.



来源:https://stackoverflow.com/questions/45707643/unhandeld-exception-in-production-system-net-http-4-1-1-1-filenotfoundexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!