I am really stuck on this one and could use some help.
This problem started when I added an async method involving httpclient to a class library. I call the class library from a short test console application. When it gets to the async method I get an exception:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Net.Http, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
Originally it said Could not load System.Net.Http Version 188.8.131.52 (I had version 184.108.40.206 in the project) and I was using Framework 4.5.2. I could not find a system.net.http version 220.127.116.11 for NET Framework 4.5.2 so I first updated the class library and test projects to NFW 4.7.2 and then added a reference to the version of System.Net.Http associated with this framework (i.e. choosing it from the assemblies tab).
When I look at the properties of the dll in the class lib project (toolslib) it shows 18.104.22.168. I added the same reference to the test project used to call it and it also now shows 22.214.171.124.
Additionally I added a redirect section to the app.config for toolslib
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-126.96.36.199" newVersion="188.8.131.52"/> </dependentAssembly>
I put the same lines in the app.config for the test console app.
However I still get the same issue now with it saying it can't load 184.108.40.206. I set up Fusion Logs and got the following after running and getting the exception:
*** Assembly Binder Log Entry (7/9/2020 @ 9:12:52 PM) *** The operation failed. Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\Users\smjhu\Documents\DevProjects\IDXUtil\Test\bin\Debug\Test.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = System.Net.Http, Version=220.127.116.11, Culture=neutral, ]PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///C:/Users/smjhu/Documents/DevProjects/IDXUtil/Test/bin/Debug/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = Test.exe Calling assembly : ToolsLib, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\smjhu\Documents\DevProjects\IDXUtil\Test\bin\Debug\Test.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Redirect found in application configuration file: 22.214.171.124 redirected to 126.96.36.199. LOG: Post-policy reference: System.Net.Http, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Users/smjhu/Documents/DevProjects/IDXUtil/Test/bin/Debug/System.Net.Http.DLL. LOG: Attempting download of new URL file:///C:/Users/smjhu/Documents/DevProjects/IDXUtil/Test/bin/Debug/System.Net.Http/System.Net.Http.DLL. LOG: Attempting download of new URL file:///C:/Users/smjhu/Documents/DevProjects/IDXUtil/Test/bin/Debug/System.Net.Http.EXE. LOG: Attempting download of new URL file:///C:/Users/smjhu/Documents/DevProjects/IDXUtil/Test/bin/Debug/System.Net.Http/System.Net.Http.EXE. LOG: All probing URLs attempted and failed.
The only thing I can see from the logs is it appears to be attempting to look for the dll in the test/bin/debug folder.
I tried setting the dll to copy local but same result.
I then tried copying the system.net.http dll into the bin/debug folder manually but then when I hit that method I get a badimage exception saying I cannot use reference assemblies.
BTW also tried updating system.net.http with nuget with same result
User contributions licensed under CC BY-SA 3.0