我在运行.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程序,
发布评论