2011-12-14 83 views
23

我想“打造”我在VS2010 MVC3 Web应用程序然而不断收到以下错误:生成错误 - “System.Web.Mvc.ModelClientValidationRule”冲突

错误2型“System.Web.Mvc .ModelClientValidationRule'存在于'c:\ Program Files(x86)\ Microsoft ASP.NET \ ASP.NET MVC 3 \ Assemblies \ System.Web.Mvc.dll'和'c:\ Program Files文件(x86)\ Microsoft ASP .NET \ ASP.NET Web Pages \ v2.0 \ Assemblies \ System.Web.WebPages.dll'C:\ Users \ brownp \ Documents \ Visual Studio 2010 \ Projects \ Cab \ Cab \ Models \ AccountModels.cs 223 28 Cab

另外,每次打开解决方案时,它都会提示我以下内容:

VS2010 error when opening solution

我通过Web平台安装程序进行安装,但安装成功,但每次打开解决方案时都会再次出现此消息。

任何人都可以提供任何指导?

感谢保罗

回答

44

安装今天MVC4测试后,我的几个MVC 3的项目将不会编译。 (ModelClientValidationRule冲突)此修复程序是:

编辑:

ProjectName.csproj 

变化

<Reference Include="System.Web.WebPages"/> 

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

我终于可以验证,只是把版本1.0.0.0 =就足够了。因此, 2013-03-01 17:52:24

13

好的尝试这种解决方案

  1. 在根Web.config文件中,使用关键webPages:Version和值1.0.0.0添加一个新条目。

2.In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.

3.Locate the following assembly references:

<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 "/> 

4.Save的变化,关闭项目(的.csproj)文件您正在编辑,然后右键单击该项目并选择重新加载。

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

也尝试:http://www.asp.net/learn/whitepapers/mvc4-release-notes#_Toc303253815

10

从溶液中引用删除System.Web.WebPages。这就是全部。

3

避免这一冲突的最好办法是 -

  1. 转到解决方案资源管理
  2. 参考
  3. 右键单击System.Web.WebPages
  4. 删除

现在运行应用程序,并享受!

0

这个问题与您在VS2010中描述的相同,在我的VS2015中使用较新版本的MVC(V5)发生。

这里是我是如何能够解决这个问题:

  • 更新的NuGet包到最新版本。

  • 在您的项目中,删除Microsoft.AspNet.WebPages的引用。然后,通过使用最新的软件包(使用“浏览...”),重新添加引用:

    C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40

  • 确保所有项目都引用相同的组件,如果没有,则上述解决这些问题。然后,重新构建解决方案。在我的情况下,它修复了错误。

检查Web.config文件,并修复设置,如:

<appSettings> 
<add key="webpages:Version" value="3.0.0.0" /> 
<add key="webpages:Enabled" value="true" /> 
... 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 
    </dependentAssembly>