-
Notifications
You must be signed in to change notification settings - Fork 424
"Could not load System.Net.Http, Version=4.2.0.0" on .NET 4.7.1 together with "System.Collections.Immutable" #891
Comments
I just tried your repro solution, and launching it works fine for me, and I made sure that the routeconfig method was being called so that Class1 was returning in fact an HTTPClient back. Two things I changed in order to make it work:
After both of those minimal changes, the app ran just fine. |
ItemGroup section for the NuGetHttpRepro.csproj: <ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Net.Http.WebRequest" />
<PackageReference Include="Antlr" Version="3.5.0.2" />
<PackageReference Include="AWSSDK.Core" Version="3.3.26" />
<PackageReference Include="bootstrap" Version="4.1.3" />
<PackageReference Include="jQuery" Version="3.3.1" />
<PackageReference Include="jQuery.Validation" Version="1.17.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.7.2" />
<PackageReference Include="Microsoft.ApplicationInsights.Agent.Intercept" Version="2.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.7.2" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.7.2" />
<PackageReference Include="Microsoft.ApplicationInsights.Web" Version="2.7.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.7.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.7.2" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.6" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.6" />
<PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.6" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" Version="3.2.10" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="Modernizr" Version="2.8.3" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="popper.js" Version="1.14.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="WebGrease" Version="1.6.0" />
</ItemGroup> And for NuGetHttpRepro.Library <ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
</ItemGroup> |
Don't forget to run |
Thank you for the time you have taken on this issue! I find that my repro stops working (in a VM) under Windows 10 .NET 4.7.2. I am currently unable to migrate to 4.7.2 on my main machine, though. So feel free to close this issue since there's nothing to fix. Migrating to PackageReference is certainly an interesting option. On my real project there are a few things blocking me from doing that:
I have tried to migrate NuGetHttpRepro to PackageReference according to your instructions. I was able to migrate the library project but the web project did not quite work. I deleted all bin, obj and .vs folders from the NuGetHttpRepro solution after using the VS feature to migrate the library to PackageReference and after using your XML to alter my csproj file. VS now does not show any package references and the build fails because System.Net.Http is not found. I wonder what I did wrong to cause this. Anyway, I'm giving up on this for now. If you want feedback on the migration feature: Maybe users should be able to keep individual packages in the packages.config format. I'd be able to solve the Microsoft.SqlServer.Types that way. Also, a checkbox to turn off the backup would be a good idea. Serious development always happens under source control.
That appears entirely correct and I will aim at migrating to PackageReference once that becomes feasible. But currently PackageReference introduces new problems as well, so that path is barred for the time being (or would come with significant effort). For now I'm happy that I have reached a state on my real project that works at all. It involved manually changing references and binding redirects contrary to what the tooling did. I'm sure some of the issues that I experienced were user errors. I'm also sure there are tooling bugs. Weird things happen from time to time. As a customer I feel this technology is very promising but also not very mature yet. Feel free to close this issue. |
Closing as dupe of #936 |
I will attach a repro solution that I have created as follows:
When this application is started it immediately crashes:
Findings/bugs:
If you now uninstall the seemingly unrelated (and unused) package System.Collections.Immutable the project starts working!
Currently, on the latest Visual Studio and on .NET 4.7.1 it seems very easy to run into almost unfixable tooling bugs. It really is not very hard to trigger the conditions for these issues. I suspect many people are running into this and indeed, when you search the web or this issue tracker there are many reports of very strange issues around .NET 4.7.1 and System.Net.Http, System.Runtime and a few others.
These bugs are extremely hard to track down with no clear workaround. It took me two days now to investigate multiple such issues. Someone new to .NET couldn't fix these in 10 years.
NuGetHttpRepro.zip
The text was updated successfully, but these errors were encountered: