.net - MVC 3 "is incompatible with .NET Framework 4"

标签 .net visual-studio-2010 asp.net-mvc-3

不知道怎么可能,但是我得到了这个错误信息:

那是在我完成之后发生的:

  • 已安装.NET 4和Visual Studio 2010 Professional
  • 使用WPI + NuGet +一些时髦的时髦库软件包
  • 安装了VS 2010 SP1软件包
  • 使用WPI
  • 安装了ASP.NET MVC 3(包括2011年4月的工具更新)程序包
  • 创建了一个新的带有Razor支持的空MVC 3 C#Web应用程序
  • 无法构建它,因为出现此错误:Warning 3 The primary reference "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
  • 检查项目是否以.NET 4为目标。
  • 删除了对System.Web.Mvc的引用,并尝试再次添加它(版本3.0),并得到了上述错误消息(上面的截图)
  • 尝试重新安装了一些组件,以随机顺序执行了一些先前的步骤,在我的计算机上撒了一些原始的鸡血,然后一次又一次地重新启动Windows,所有这些都无济于事。

  • 我敢打赌,解决方案是平庸的,但一定是在星期五的下午。

    顺便说一句,我还安装了VS 2008,MVC 1,MVC 2和所有.NET Framework版本并可以正常使用。

    更新1:
    实际上,针对.NET 4的 MVC 2 项目存在完全相同的问题。

    更新2:我觉得这有点相关-我确实很想念C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0文件夹中的 System.Data.Linq.dll (尽管存在 System.Data.Linq.xml )

    我重新安装了.NET 4框架,但是并没有解决问题。

    最佳答案

    只是在使用其他dll时遇到了类似的问题(无法添加引用)。清除最近添加的引用列表确实有帮助。

    关于.net - MVC 3 "is incompatible with .NET Framework 4",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6307944/

    相关文章:

    c# - 将单个 StyleCop 规则设置为构建错误

    visual-studio-2010 - VS2010开发服务器可以发邮件吗?

    c# - ExpectedExceptionAttribute 在 MSTest 中不起作用

    asp.net - 定位 CSS 中的事件链接

    c# - .NET DateTime Parse 抛出异常

    c# - 什么让我困惑....NET 语言是 Windows(独立)应用程序的主流语言吗?

    c# - Cosmo Sql Db - 使用连续 token 查询数据永远不会完成

    c# - WPF 中 MediaElement 中的视频淡入淡出

    c# - 我如何在 ASP.NET MVC Controller 中使用 Lazy<T>?

    c# - System.Drawing 不存在?