ModelClientValidationRule conflict

2020-05-14 01:54发布

问题:

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

回答1:

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



回答2:

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 "/>