bandariiswear

幽艳纷相竞 秾纤各自奇 虽然春烂漫 也要笔扶持 清人题画诗

导航

System.Web.Mvc.ModelClientValidationRule 冲突解决方法

随着 ASP.NET MVC 4 的发布,不少用户的开发环境中同时存在 ASP.NET MVC 3 和 ASP.NET MVC 4 ,但是安装 ASP.NET MVC 4 之后再运行 ASP.NET MVC 3 版本的程序时会出现以下类型的错误

错误    1    类型“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”中    D:\Projects\Visual Studio 2010\MvcWijmoApplication1\MvcWijmoApplication1\Models\AccountModels.cs    242    28    MvcWijmoApplication1

 

原因是 ASP.NET MVC 3 应用程序是使用的 RTM 版本,如果需要同时使用 3 和 4 两个版本,需要修改应用程序的配置。操作步骤如下:

1、在 web.config 中添加以下配置信息

  1: <appSettings>
  2:     <add key="webpages:Version" value="1.0.0.0"/>
  3:     <add key="ClientValidationEnabled" value="true"/>
  4:     <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  5: </appSettings>

 

2、修改工程文件 Projectname.csproj

找到以下配置信息

  1: <Reference Include="System.Web.WebPages"/> 
  2: <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" />

 

重现加载工程,并重新编译工程。

 

http://blog.gcpowertools.com.cn/post/2013/05/07/SystemWebMvcModelClientValidationRule-20130507002.aspx

posted on 2014-08-21 10:26  YEKEYISHUO  阅读(273)  评论(0)    收藏  举报