代码分析—“CA0052 没有选择要分析的目标”(VS2012)
情况:
1.未采用代码分析时程序正常编译
2.采用代码分析,会提示“没有选择分析目标”或“未加载制定版本的程序集”...的错误
分析:
是由于代码分析依赖程序集的强签名,包括版本
解决方案:
1.修改代码分析工具的配置项:
FxCopCmd.exe.config里节点AssemblyReferenceResolveMode的Value值StrongName修改为StrongNameIgnoringVersion或None
2.修改当前分析的项目:
.csproj增加节点
1 2 3 | <PropertyGroup> <CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions> </PropertyGroup> |
原文:http://stackoverflow.com/questions/26058751/visual-studio-2012-code-analysis-error-ca0058
The underlying issue is due to the combination of two facts:
Prism.UnityExtensions
version4.1.0.0
referencesUnity
in version2.1.505.0
, with a strong name, but you have a newer version, strongly signed with version3.0.0.0
;- In its default mode of operation, FxCop insists that the assembly name must match the reference, including having the exact version number, thereby ignoring assembly redirection (which is the only thing that allows that combination of assemblies to work at runtime);
Meaning that, this mess is not your fault, simply the result of attempting to use an "unexpected" combination of library versions, and of an oversight in FxCop's assembly resolution logic.
The main way to get past that issue is to set FxCop's AssemblyReferenceResolveMode
to StrongNameIgnoreVersion
. There are ways to achieve that, one on a per-machine setting, and the other on a per-project setting.
- One is to do as you did, to set
AssemblyReferenceResolveMode
toStrongNameIgnoreVersion
in eitherFxCopCmd.exe.config
(from VS12 invocation) orFxCop.exe.config
(command-line call toFxCop.exe
); - The other is to add a line in each
.csproj
file, inside of aPropertyGroup
XML element:
<PropertyGroup>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
</PropertyGroup>
I would recommend using the per-project setting for any project that you intend to share with other people.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
· .NET 进程 stackoverflow异常后,还可以接收 TCP 连接请求吗?
· 本地部署 DeepSeek:小白也能轻松搞定!
· 基于DeepSeek R1 满血版大模型的个人知识库,回答都源自对你专属文件的深度学习。
· 在缓慢中沉淀,在挑战中重生!2024个人总结!
· 大人,时代变了! 赶快把自有业务的本地AI“模型”训练起来!
· Tinyfox 简易教程-1:Hello World!