44

I have installed vs 2011 developer preview side by side with vs 2010. Now when i run my asp.net mvc 3 project in vs 2010 I am getting the following error in my project where i am using ModelClientValidationRule.

The type System.Web.Mvc.ModelClientValidationRule exists in both c:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll and c:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll

Is this related to vs 2011 conlict with vs 2010 or something else

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Tassadaque
  • 8,129
  • 13
  • 57
  • 89

2 Answers2

72

The accepted answer was "useful" but after installing MVC4 beta today, a few of my MVC 3 projects would not compile. (ModelClientValidationRule conflict) The fix was:

Edit:

ProjectName.csproj

Change

<Reference Include="System.Web.WebPages"/> 

To

<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
Tom Stickel
  • 19,633
  • 6
  • 111
  • 113
  • 36
    Or, more simply, just remove the reference to System.Web.WebPages. – Jay Borseth Apr 22 '12 at 16:49
  • I'm not sure that works off hand, I've moved onto to another contract job, so I cannot validate that it will work, if you experienced the problem, and got the results you desire then kudos. thx – Tom Stickel Apr 22 '12 at 19:39
  • 3
    @Saulius I wouldn't throw the baby out with the bathwater though. System.Web.WebPages is sometimes needed. Even Scott H. has it as part of his Bin Deploy http://www.hanselman.com/blog/BINDeployingASPNETMVC3WithRazorToAWindowsServerWithoutMVCInstalled.aspx – Tom Stickel May 30 '12 at 05:51
  • @Tom Stickel didn't stumble at it till now. Just trying to be minimalistic. If my code breaks I vote up your answer :-) – Saulius May 30 '12 at 07:58
  • 5
    Adding ", Version=1.0.0.0" is sufficient. – Stefan Steiger Dec 03 '12 at 06:59
  • I just ran into this again about a year later! I opened with VS 2010 a project I had downloaded and it gave the error, so I knew I planned on making changes to the application with VS 2012, so I opened with VS 2012 and it still gives the same error – Tom Stickel Feb 16 '13 at 04:18
  • 2
    @Quandary Yes, I was finally able to validate that just adding Version=1.0.0.0 is sufficient. Thus Thanks – Tom Stickel Feb 16 '13 at 04:25
  • If you happen to be using the TagBuilder class then just removing the reference to System.Web.WebPages is *not* a solution as this is where this class got 'moved to' for the MVC 3 release -- it was apparently previously included in the MVC assembly. – Christopher King Dec 31 '13 at 15:45
  • Yes, I agree with you Christopher – Tom Stickel Dec 31 '13 at 18:45
41

please see the below release notes :

http://www.asp.net/learn/whitepapers/mvc4-release-notes

Installing ASP.NET MVC 4 Developer Preview breaks ASP.NET MVC 3 RTM applications.

ASP.NET MVC 3 applications that were created with the RTM release (not with the ASP.NET MVC 3 Tools Update release) require the following changes in order to work side-by-side with ASP.NET MVC 4 Developer Preview. Building the project without making these updates results in compilation errors.

http://www.asp.net/learn/whitepapers/mvc4-release-notes#_Toc303253815

tugberk
  • 57,477
  • 67
  • 243
  • 335