无法从程序集'mscorlib加载类型'System.Runtime.CompilerServices.ExtensionAttribute',版本= 4.0.0.0错误

时间:2022-08-18 20:17:54

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

我的.NET站点在Localhost上工作正常。但是,在我的服务器上。我收到这个错误。

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

“无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Runtime.CompilerServices.ExtensionAttribute'。”

(Can't post screenshot, due to Stack Overflow policy)

(由于Stack Overflow策略,无法发布截图)

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

这与asp:ScriptManager有关。我之前在同一台服务器上使用过它,但现在,它显示错误。

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

PS:当我删除Scriptmanager时,代码运行正常。

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

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

2 个解决方案

#1


18  

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.

当您针对.Net 4.5编译应用程序,然后在仅安装了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

在.Net 4.5中,ExtensionAttribute类已从System.Core移至mscorlib。 System.Core中有一个类型转发器,它指向mscorlib中的新位置。如果您针对4.5编译应用程序,它将期望在mscorlib中找到ExtensionAttribute。如果你然后在4.0上运行它将得到这个例外,因为实际上生活在4.0中的System.Core中

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

要解决此问题,请将4.5部署到服务器或确保您针对4.0进行构建

#2


-1  

JUST install microsoft framework v4.5 or higher on you pc or server it's worked for me very well

只需在您的PC或服务器上安装microsoft framework v4.5或更高版本,它对我来说非常有用

#1


18  

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.

当您针对.Net 4.5编译应用程序,然后在仅安装了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

在.Net 4.5中,ExtensionAttribute类已从System.Core移至mscorlib。 System.Core中有一个类型转发器,它指向mscorlib中的新位置。如果您针对4.5编译应用程序,它将期望在mscorlib中找到ExtensionAttribute。如果你然后在4.0上运行它将得到这个例外,因为实际上生活在4.0中的System.Core中

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

要解决此问题,请将4.5部署到服务器或确保您针对4.0进行构建

#2


-1  

JUST install microsoft framework v4.5 or higher on you pc or server it's worked for me very well

只需在您的PC或服务器上安装microsoft framework v4.5或更高版本,它对我来说非常有用