尝试使用.netstandard 2程序集时Web Api 2运行时错误 [英] Web Api 2 run-time error when trying to use .netstandard 2 assembly
问题描述
我有一个引用.net 4.6.1的Asp.net WebApi 2站点。到目前为止,该站点一直在引用PCL程序集(便携式类库),以与UWP& amp; Xamarin,没有问题。现在,我尝试按照建议将PCL更改为NetStandard2.0程序集,但在站点启动时收到错误。
I have an Asp.net WebApi 2 site referencing .net 4.6.1. Up till now the site was referencing a PCL assembly (portable class library), for compatibility with UWP & Xamarin, without issues. Now I am trying to change that PCL to a NetStandard2.0 assembly, as recommended, but am receiving an error at site start up.
错误在-下方p>
The error is below -
找不到方法:
'System.Collections.ObjectModel.Collection`1
System.Web.Http.HttpConfiguration。 get_MessageHandlers()'。
Method not found: 'System.Collections.ObjectModel.Collection`1 System.Web.Http.HttpConfiguration.get_MessageHandlers()'.
有什么想法吗?
谢谢
Any ideas? Thanks
推荐答案
我也得到了同样的东西。我将此添加到我的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>
I was getting the same thing. I added this to my web.config and it worked.
<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>
哦,绑定重定向的乐趣。
Oh the joys of Binding Redirects.
这篇关于尝试使用.netstandard 2程序集时Web Api 2运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!