安裝asp.net mvc4以後,以前的mvc3項目編譯時報這個錯「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\Microso...」web
從新安裝mvc3也許能夠解決這個問題,不過還會覆蓋mvc4的配置,能夠經過修改引用來解決:mvc
1.打開根目錄下web.config文件添加一下配置項:app
<appsettings>asp.net
<add key="webpages:Version" value="1.0.0.0"/>工具
<add key="ClientValidationEnabled" value="true"/>.net
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>ip
</appsettings>it
2.卸載項目,用編輯工具打開ProjectName .csproj.文件,替換如下配置項:io
<reference include="System.Web.WebPages"/>編譯
<reference include="System.Web.Helpers"/>
替換成:
<reference include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
<reference include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
3.從新加載項目,編譯OK。