RC的WebAPI“System.Runtime.CompilerServices.ExtensionAttribute”从程序集“mscorlib程序, [英] WebAPI RC 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib,

查看:165
本文介绍了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引用程序集在上投放开关,而不是路径实施,在这个博客帖子描述:<一href=\"http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx\">http://www.mattwrock.com/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 .net4 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: http://www.mattwrock.com/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程序,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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