Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 3 "is incompatible with .NET Framework 4"

Not sure how even that could be possible, but I have got this error message:

System.Web.Mvc Version=3.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35" is incompatible with .NET Framework 4 In order to add it you should to change the project's target to a compatible framework first

That happened after I've:

  1. installed .NET 4 and Visual Studio 2010 Professional
  2. installed VS 2010 SP1 package using WPI + NuGet + some groovy funky library packages
  3. installed ASP.NET MVC 3 (includes April 2011 Tools Update) package using WPI
  4. created a new empty MVC 3 C# Web Application with Razor support
  5. failed to build it because got this error: 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".
  6. checked if the project targets .NET 4. It does
  7. removed the reference to System.Web.Mvc and tried to add it again (version 3.0) and got the aforementioned error message (screenshot above)
  8. tried out re-installing some components, performed some of the previous steps in random order, spilled some virgin chicken's blood over my computer and restarted Windows again and again, all that to no avail.

I bet the solution is banal, but it must be that its Friday afternoon.

By the way, I have also VS 2008, MVC 1, MVC 2, all .NET framework versions installed and functional.


Update 1: In fact, I have exactly the same problem with MVC 2 projects targeting .NET 4.


Update 2: I feel that this is somehow related - I do really miss System.Data.Linq.dll in the folder C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 (though System.Data.Linq.xml is present)

I reinstalled .NET 4 framework but that didn't fix the problem.

like image 795
Maxim Gueivandov Avatar asked Jun 10 '11 14:06

Maxim Gueivandov


People also ask

Which .NET framework supports MVC?

The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.

Is ASP.NET MVC 5 cross platform?

The main difference between ASP.NET Core and ASP.NET MVC 5 is their cross-platform approach. ASP.NET Core can be used on Windows, Mac, or Linux, whereas ASP.NET MVC 5 can only be used for applications on Windows.


2 Answers

Just had a similar problem (unable to add a reference) with a different dll. Clearing the list of recently added references did help.

like image 113
ulu Avatar answered Sep 19 '22 21:09

ulu


Manually uninstall MVC3, Download Microsoft Web Platform Installer and reinstall MVC3 through WPI - that usually does a pretty good job of ensuring prerequisites are present.

like image 38
BonyT Avatar answered Sep 17 '22 21:09

BonyT