I have an ASP.NET MVC application which started to misbehave after the last NuGet package updates. The web app uses .NET Framework 4.6.1, and the developer machine is a Windows Server 2012 R2 Essentials. One package I use is Stripe.NET for payment processing. Its earlier versions required only <package id="System.Net.Http" version="4.0.0" targetFramework="net461" />
. Visual Studio marked that there's a newer version of that (at that time it was 4.3.0
), but when I updated that it pulled in a ton of packages. So I simply reverted back that dependency to 4.0.0
, Stripe didn't require newer.
Then lately I introduced Nager.Date
to handle work days and holidays. The latest update (v 1.5.0
) of that package requires "NETStandard.Library" version="1.6.1"
. Just like upgrading System.Net.Http
to 4.3.0
, upgrading to that Nager.Date
pulls in the ton of packages I mention. In summary: sooner or later I have to cave in and update.
The pulled-in packages:
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net461" />
<package id="System.IO" version="4.3.0" targetFramework="net461" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Http" version="4.3.1" targetFramework="net461" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
I would still be in peace with all of this if in the end I won't be presented with:
Exception thrown: 'System.MissingMethodException' in ThruThink.dll
Additional information: Method not found: 'Void System.Web.Http.HttpResponseException..ctor(System.Net.Http.HttpResponseMessage)'.
I couldn't figure out why this happened. Nager.Date owner gave me an idea: he generated the latest package with VS 2017, so I installed that hoping that it'll install some assemblies which will magically solve this exception. But that didn't happen so far.
I don't understand the list of these packages. A lot of them are foundational libraries which supposed to be part of the CLR itself (like System.IO, System.Console, ...) and available without a NuGet package. Maybe one clue is that I see Microsoft.NETCore.Platforms
, although I'm with .NET 4.6.1, not using .NET Core. I haven't played with .NET Core too much yet, but those packages make sense for .NET Core infrastructure. What's going on?
The newest version of Nager.Date
didn't pull in all of those dependencies and I don't face this problem any more.
You're hitting System.Net.Http OOB versioning issue, see Broken System.Net.Http 4.1.1-4.3.0 post-mortem. An assembly redirect should fix the problem:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
You may need to redirect to 4.1.1.2 or 4.0.0.0 instead, depending on your project and the libraries you reference.
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