同时安装vs2010和VS2012后IEnumerable<ModelClientValidationRule>编译错误

    今天安装了VS2012后,发现原来的一个MVC项目编译时发生错误,具体错误信息如下:

错误    4    类型“System.Web.Mvc.ModelClientValidationRule”同时存在于“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”中    

查阅一些资料后,解决方法如下:

Step 1

修改Web.config,在  <appSettings>新增<add key="webpages:Version" value="1.0.0.0"/>

1   <appSettings>
2     <add key="webpages:Version" value="1.0.0.0"/>
3   </appSettings>


Step 2

关闭解决方案

用记事本打开 项目名称.csproj

找到

1 <Reference Include="System.Web.WebPages"/> 
2 <Reference Include="System.Web.Helpers" />

改成

1     <Reference Include="System.Web.WebPages, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 
2     <Reference Include="System.Web.Helpers, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

保存,OK。现在再重新打开编译一下试试。

参考:http://forums.asp.net/t/1723108.aspx/1

原文地址:https://www.cnblogs.com/ahwwmb/p/2700832.html