在Visual Studio 2010中引用mscorlib


  • 我的目标框架是.NET Framework 4。
  • 该项目是一个 MVC 3 项目。
  • 我正在使用Visual Studio 2010。
  • 视窗 7 64 位

正在尝试让一个旧项目在我全新安装的 Windows 7 64 位上工作。当我尝试编译项目时,多次出现以下错误:

 Error  11  Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'

我已经阅读了有关同一错误的多个问题,但似乎没有一个解决方案有效,并且与其他目标框架或不同版本的 MVC 相关。更令人沮丧的是,这个完全相同的项目在我的同事计算机上完美编译。

据我了解,我收到此错误的原因是该项目正在 System.Core 中查找 System.Runtime.CompilerServerices,但它已移至 mscorlib。

正在尝试重新播放 mscorlib,但当我尝试将其添加为编译引用时,我收到以下消息:

当我尝试添加 mscorlib.dll 2.0 时:

 A reference to 'mscorlib.dll' could not be added. The ActiveX type library 'C:WindowsMicrosoft.NETFrameworkv2.0.50727mscorlib.tlb' was exported from a .NET assembly and cannot be added as a reference. Add a reference to the .NET assembly instead.

当我尝试添加 mscorlib 时.dll 2.4:

 A reference to 'mscorlib.dll' could not be added. The ActiveX type library 'C:WindowsMicrosoft.NETFrameworkv4.0.30319mscorlib.tlb' was exported from a .NET assembly and cannot be added as a reference. Add a reference to the .NET assembly instead.

因此,当我尝试将 mscorlib v4.0.0.0 添加为 .NET 引用时,我收到以下错误消息:

 A reference to 'mscorlib' could not be added. This component is already automatically referenced by the build system.

我是否缺少特定更新?我需要重新引用 mscorlib 吗?如果是这样,我该怎么做?有没有办法让项目使用 System.Core.dll而不是 mscorlib?

经过一些帮助,我已经卸载了 .Net 4.5 并安装了允许项目编译的 4.0,但是我收到以下错误:

 Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies. An attempt was made to load a program with an incorrect format.

为了解决这个问题,我必须重新安装.Net 4.5并重新应用VS 2010 SP1。该项目现已开始工作!

最新更新