Maxim Gueivandov
Maxim Gueivandov

Reputation: 2385

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.

Upvotes: 9

Views: 4205

Answers (3)

FabianSilva
FabianSilva

Reputation: 405

this question is a little old... but if anyone else have the same message when adding a reference to a project this can be a good solution:

I downloaded PowerCommands for vs2010 http://visualstudiogallery.msdn.microsoft.com/e5f41ad9-4edc-4912-bca3-91147db95b99

it allows to copy a reference from one project to another, I do this and this works... IO suppose that editing the project file manually can work too (not tested)

Upvotes: 1

ulu
ulu

Reputation: 6092

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

Upvotes: 2

BonyT
BonyT

Reputation: 10940

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.

Upvotes: 1

Related Questions