未能从程序集“mscorlib程序,版本= 4.0.0.0错误加载类型”System.Runtime.CompilerServices.ExtensionAttribute“程序、加载、错误、类型

2023-09-03 03:40:25 作者:就这样、离去

我是业余的.NET程序员。

I am amateur .NET programmer.

我的网站工作正常在本地主机上。但是,我的服务器上。我得到这个错误。

My site is working fine on Localhost. But, on my Server. I get this error.

无法加载从组装​​式System.Runtime.CompilerServices.ExtensionAttribute'mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'。

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

广东话帖子截图,堆栈溢出政策的堂妹。

Cant post screenshot, coz of stack overflow policy.

这件事情做的asp:ScriptManager的。我之前已经用它在同一台服务器上,但现在,它的显示错误。

It's something to do with asp:ScriptManager. I have used it before on the same server, but now, it's showing an error.

PS:当我删除的ScriptManager中,code运行正常

PS: When I remove Scriptmanager, the code runs fine.

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

请帮我。

推荐答案

此错误出现时,编译在.NET 4.5的应用程序,但随后一台机器,只有4.0安装上运行它有关。

This error comes about when you compile an application against .Net 4.5 but then run it on a machine that only has 4.0 installed.

在净4.5 ExtensionAttribute 类是从System.Core程序转移到MSCORLIB。有在System.Core程序类型转发指向在mscorlib中的新位置。如果您对4.5编译应用程序将希望找到 ExtensionAttribute 在mscorlib中。如果你运行它针对4.0,因为在实际生活中System.Core程序在4.0,你会得到这个异​​常

In .Net 4.5 the ExtensionAttribute class was moved from System.Core to mscorlib. There is a type forwarder in System.Core that points to the new location in mscorlib. If you compile an app against 4.5 it will expect to find ExtensionAttribute in mscorlib. If you then run it against 4.0 you will get this exception because in actually lives in System.Core in 4.0

要解决这个问题无论是部署4.5服务器或确保您筑起4.0

To fix this either deploy 4.5 to the server or make sure that you build against 4.0