Asp.net mvc 3 比较属性是';在TeamCity中构建时未找到(在Windows Server 2012 RC上)

Asp.net mvc 3 比较属性是';在TeamCity中构建时未找到(在Windows Server 2012 RC上),asp.net-mvc-3,teamcity,windows-server,Asp.net Mvc 3,Teamcity,Windows Server,我正在尝试在TeamCity上构建一个MVC项目,该项目安装在带有Windows server 2012 RC的服务器上 我收到以下错误。这看起来和MVC版本有点冲突,这是我在谷歌搜索时发现的。我按版本明确引用system.web.mvc等,所以我不知道问题出在哪里。有什么想法吗 Models\AccountModels.cs(26, 10): error CS0246: The type or namespace name 'Compare' could not be found (are y

我正在尝试在TeamCity上构建一个MVC项目,该项目安装在带有Windows server 2012 RC的服务器上

我收到以下错误。这看起来和MVC版本有点冲突,这是我在谷歌搜索时发现的。我按版本明确引用system.web.mvc等,所以我不知道问题出在哪里。有什么想法吗

Models\AccountModels.cs(26, 10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) 
Models\AccountModels.cs(26, 10): error CS0104: 'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute' 
Models\AccountModels.cs(64, 10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) 
Models\AccountModels.cs(64, 10): error CS0104: 'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute' 

必须在
Compare
属性中明确指定名称空间,如

[System.Web.Mvc.Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
而不是

[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
您还可以添加:

using System.Web.Mvc;

在您的.cs文件顶部,我将我的站点从MVC Framework 4更新为4.5.1,并且(在使用NuGet命令行更新各种库之后)收到了相同的错误。我已经调用了名称空间“using System.Web.Mvc;”在我的.cs文件的顶部。只有当我使用完整路径“System.Web.Mvc.Compare”时,这才起作用。

从标题中使用System.Web.Mvc删除在升级到VS2012和相关项目目标更改后,也开始发现此问题。