【问题标题】:Referencing mscorlib in Visual Studio 2010在 Visual Studio 2010 中引用 mscorlib
【发布时间】:2023-03-23 02:40:01
【问题描述】:
  • 我的目标框架是 .NET Framework 4。
  • 该项目是 MVC 3 项目。
  • 我使用的是 Visual Studio 2010。
  • Windows 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:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.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:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.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?

【问题讨论】:

  • 您是否安装了 VS 2010 SP1 和所有更新?
  • 是的,所有 Windows 7 更新和 VS 2010 SP1 都已安装。
  • 我目前正在重新应用 SP1,以确保它已正确安装。
  • 可能存在参考错误的问题。您确定您的项目/解决方案指向正确的框架版本吗?
  • @WarGravy - 我的意思是所有 VS 2010 更新,例如 Web 工具更新和 Web 标准更新...

标签: c# .net asp.net-mvc visual-studio-2010 visual-studio


【解决方案1】:

经过一些帮助,我卸载了 .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。该项目正在运行!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    相关资源
    最近更新 更多