RC的WebAPI“System.Runtime.CompilerServices.ExtensionAttribute”从程序集“mscorlib程序,

编程入门 行业动态 更新时间:2024-10-26 06:37:45
本文介绍了RC的WebAPI“System.Runtime.CompilerServices.ExtensionAttribute”从程序集“mscorlib程序,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在运行.NET4,我试图让工作在服务器上的应用程序的WebAPI。该API本地工作正常。

  

未能从程序集'mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'加载类型System.Runtime.CompilerServices.ExtensionAttribute。

我需要做什么改变得到这个我的服务器上运行?

解决方案

你确定你对编译.NET 4中,而不是.NET 4.5?我们搬到ExtensionAttribute到MSCORLIB在.NET 4.5(这样我们可以把扩展方法在mscorlib中)。我希望看到这样的一个错误,如果你对编译.NET 4.5的东西,并试图在.NET 4中运行它。

编辑:其实,如果你正在使用ILMerge,你需要使用的路径,.NET 4.0引用程序集在上投放开关,而不是路径实施,在这个博客帖子描述:www.mattwrock/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx

I have an webapi application running 4 that I am trying to get working on a server. The api works fine locally.

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

What do I need to change to get this to work on my server?

解决方案

Are you sure you were compiling against .NET 4 and not .NET 4.5? We moved ExtensionAttribute to mscorlib in .NET 4.5 (so we could put extension methods in mscorlib). I'd expect to see an error like that if you compiled something against .NET 4.5 and tried to run it on .NET 4.

EDIT: Actually, if you are using ILMerge, you need to use the path to the .NET 4.0 reference assemblies in the targetplatform switch, instead of the path to the implementation, as described in this blog post: www.mattwrock/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx

更多推荐

RC的WebAPI“System.Runtime.CompilerServices.ExtensionAttribute”从程序集“mscorlib程序,

本文发布于:2023-11-12 04:44:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   System   WebAPI   RC   Runtime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!