This error just started happening out the blue. Using Visual Studio 2017, the System.Net.Http.Formatting problem has not been brought up for several years.
I only see this message on the webpage:
Could not load file or assembly 'System.Net.Http.Formatting-Cosmo' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Along with a traceback:
=== Pre-bind state information ===
LOG: DisplayName = System.Net.Http.Formatting-Cosmo
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Net.Http.Formatting-Cosmo | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/George/OneDrive/SignupList/SignupList/
LOG: Initial PrivatePath = C:\Users\George\OneDrive\SignupList\SignupList\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\George\OneDrive\SignupList\SignupList\web.config
LOG: Using host configuration file: C:\Users\George\OneDrive\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/George/AppData/Local/Temp/Temporary ASP.NET Files/vs/6cc2628d/51b3c1a6/System.Net.Http.Formatting-Cosmo.DLL.
LOG: Attempting download of new URL file:///C:/Users/George/AppData/Local/Temp/Temporary ASP.NET Files/vs/6cc2628d/51b3c1a6/System.Net.Http.Formatting-Cosmo/System.Net.Http.Formatting-Cosmo.DLL.
LOG: Attempting download of new URL file:///C:/Users/George/OneDrive/SignupList/SignupList/bin/System.Net.Http.Formatting-Cosmo.DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Seems to stop in trying to find System.Net.Http.Formatting which has the right version for the DLL in the config.
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
I am using ASP.NET but not MVC, I have no idea why System.Net.Http.Formatting is needed. Cosmo is the name of my computer. I hope the -Cosmo is not an issue, I do not understand why is there.
I did everything mentioned in the previous 4-year-old post in Stack Overflow - Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified with nothing solving it. I found other posts and played with Microsoft.AspNet.WebApi.Core V 5.2.4 which puts System.Net.Http.Formatting V 5.2.3.0.
The Local Copy property is set to True on the System.Net.Http.Formatting Reference. All the packages her been re-got. The project has been re-initialized. I have tried everything suggested that I could find.
Without Microsoft.AspNet.WebApi.Core, if I compile I get compile errors complaining about System.Net.Http.Formatting missing. Add Core back and the errors disappear compiling fine. I must also remove and re-add Microsoft.AspNet.WebApi.WebHost with Microsoft.AspNet.WebApi.Core because of dependencies. The webpage when running it gives the error along with as well as on the top line of every single ASPX file in my project.
I also have Newtonsoft.Json which I have seen related to this.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2014.3.1209.45" newVersion="2014.3.1209.45" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.25.0.0" newVersion="1.25.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.25.0.0" newVersion="1.25.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
The assembly is looking for System.Net.Http.Formatting-Cosmo and attempting to download it. System.Net.Http.Formatting is sitting in bin, and I even added System.Net.Http.Formatting-Cosmo just in case. The versions match. Why is it not finding the bin DLL? Is -Cosmo a problem?
Puzzling.
George
It is fixed now, but I am not sure how it was fixed because I was trying so many different things including updating Visual Studio and getting rid of older Visual Studios which did not solve the problem but did change it a little.
I noticed that the System.Net.Http.Formatting.dll had version of 5.2.60201.0. Looking around more I saw that Microsoft.AspNet.WebApi.Client could be involved too.
Using NuGet Package Manager, I removed Microsoft.AspNet.WebApi.WebHost, Microsoft.AspNet.WebApi.Core, and Microsoft.AspNet.WebApi.Client. I then re-added the most current version 5.2.4 of all 3 of them in reverse. The Client package was at 5.2.2.
Now the dependentAssembly of System.Net.Http.Formatting in Web.config has newVersion="5.2.4.0". The version on the DLL is 5.2.60201.0, so I was expecting it to see the problem but it worked. Looking for System.Net.Http.Formatting version 5.2.4.0 seems to find 5.2.60201.0 just fine while 5.2.3.0 could not.
Just as I thought was understanding it better, it worked fine. A learning experience for sure.
In the end I believe,
should all be the same version which is confirmed in the dependencies in the NuGet Manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With