新建MVC3 编译出现 System.Web.Mvc.ModelClientValidationRule

我在vs2010 新建一个Mvc3项目,编译报一下错误:

错误 1 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' 和 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll' 兩者中都有型別 'System.Web.Mvc.ModelClientValidationRule' D:\MvcApplication1\MvcApplication1\Models\AccountModels.cs 242 28 MvcApplication1

可以如下修改,保持兼容性:

(1)修改 Web.config。增加key为webPages:Version并且value为1.0.0.0的节点,即:

<appSettings>
   
<addkey="webpages:Version"value="1.0.0.0"/>
   
<addkey="ClientValidationEnabled"value="true"/>
   
<addkey="UnobtrusiveJavaScriptEnabled"value="true"/>
</appSettings> (2)修改 ProjectName.csproj。(直接用记事本打开)
搜索:
<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"
/> 
posted @ 2013-06-26 10:15  AYUI框架  阅读(403)  评论(0编辑  收藏  举报