尝试使用.netstandard 2程序集时,Web Api 2运行时错误

Ned*_*son 2 c# asp.net asp.net-web-api .net-standard

我有一个Asp.net WebApi 2网站引用.net 4.6.1.到目前为止,该网站引用了PCL程序集(便携式类库),与UWP和Xamarin兼容,没有任何问题.现在我正按照建议将该PCL更改为NetStandard2.0程序集,但在站点启动时收到错误.

错误如下 -

找不到方法:'System.Collections.ObjectModel.Collection`1 System.Web.Http.HttpConfiguration.get_MessageHandlers()'.

有任何想法吗?谢谢

Rou*_*der 8

我得到了同样的东西.我把它添加到我的web.config并且它工作. <dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> </dependentAssembly>

哦Binding Redirects的乐趣.