在VS2012中运行代码分析时出错:无法解析类型引用

时间:2013-05-31 06:56:18

标签: visual-studio-2012 code-analysis

单击Run Code Analysis项目上下文菜单项时。建筑开始,但因以下错误而停止:

CA0001  Error Running Code Analysis 
CA0001 : The following error was encountered while reading module 'EntityFramework': 
Could not resolve type reference: 
[System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]System.ComponentModel.DataAnnotations.Schema.ColumnAttribute.   [Errors and Warnings]   (Global)

对其他项目的分析效果很好。如何消除这个问题?

2 个答案:

答案 0 :(得分:1)

我尝试了Scott Wylie提到的解决方案。我尝试在我的项目中添加对System.ComponentModel.DataAnnotations的引用,但这没有帮助。

然后我尝试将System.ComponentModel.DataAnnotations.dll直接复制并粘贴到我的bin文件夹中,这样就可以了。将dll添加到本地bin文件夹,发布解决方案,然后手动将dll添加到已发布项目的bin文件夹中(如果它没有自行复制)。

答案 1 :(得分:0)

您的应用程序可能不使用System.ComponentModel.DataAnnotations dll,但EntityFramework.dll在内部引用它。代码分析将查看所有引用的dll,并尝试解析它们的引用。如果将System.ComponentModel.DataAnnotations.dll添加到应用程序,则下次运行代码分析时此错误将消失。