MVC3 类型“System.Web.Mvc.ModelClientValidationRule”同时存在

转载文章文地址:http://hi.baidu.com/limin_agua/item/994a88c8129e09c0984aa090

问题描述:

类型“System.Web.Mvc.ModelClientValidationRule”同时存在于用VS2010
新建C# MVC3工程,选择带认证模块的,并建立test单元,F5运行,报错: 错误 CS0433: 类型“System.Web.Mvc.ModelClientValidationRule”同时存在于“c:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll”和“c:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll”

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

(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。(直接用记事本打开)
搜索:
<ReferenceInclude="System.Web.WebPages"/> 
<ReferenceInclude="System.Web.Helpers"/>
替换为:
<ReferenceInclude="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "
/>
<ReferenceInclude="System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
/>

你可能感兴趣的:(validation)