为什么“未找到方法:'Void System.Web.Http.HttpResponseException..ctor'";软件包更新后? [英] Why "Method not found: 'Void System.Web.Http.HttpResponseException..ctor" after package update?

查看:76
本文介绍了为什么“未找到方法:'Void System.Web.Http.HttpResponseException..ctor'";软件包更新后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET MVC应用程序,该应用程序在最近一次NuGet软件包更新后开始出现异常.该Web应用程序使用.NET Framework 4.6.1,而开发人员计算机是Windows Server 2012 R2 Essentials.我使用的一个软件包是Stripe.NET,用于付款处理.其早期版本仅需要<package id="System.Net.Http" version="4.0.0" targetFramework="net461" />. Visual Studio标记有一个较新的版本(当时它是4.3.0),但是当我更新它时,它引入了大量的软件包.因此,我只是将依赖关系恢复为4.0.0,Stripe不需要更新.

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.

然后我最近介绍了Nager.Date来处理工作日和节假日.该软件包的最新更新(v 1.5.0)需要"NETStandard.Library" version="1.6.1".就像将System.Net.Http升级到4.3.0一样,升级到Nager.Date也会引入大量我提到的软件包.总结:迟早我必须介入并进行更新.

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.

引入的软件包:

<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)'.

我不知道为什么会这样. Nager.Date所有者给了我一个主意:他使用VS 2017生成了最新的软件包,因此我安装了该软件包,希望它可以安装一些可以神奇地解决此异常的程序集.但这到目前为止还没有发生.

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.

我不了解这些软件包的列表.它们中的许多都是基础库,应该是CLR本身的一部分(例如System.IO,System.Console等),并且没有NuGet包就可以使用.也许有一个线索是,尽管我使用的是.NET 4.6.1,但没有使用.NET Core,但我看到了Microsoft.NETCore.Platforms.我还没有太多地使用.NET Core,但是这些包对.NET Core基础结构有意义.发生了什么事?

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?

Nager.Date的最新版本并没有吸收所有这些依赖关系,我也不再面对这个问题.

The newest version of Nager.Date didn't pull in all of those dependencies and I don't face this problem any more.

推荐答案

您遇到System.Net.Http OOB版本控制问题,请参见

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>

根据项目和引用的库,您可能需要重定向到4.1.1.2或4.0.0.0.

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.

这篇关于为什么“未找到方法:'Void System.Web.Http.HttpResponseException..ctor'";软件包更新后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆