程序集绑定重定向和代码分析 [英] Assembly Binding Redirection and Code Analysis
问题描述
我在Visual Studio 2010的Mvc 3.0.0.0项目中使用DotNetOpenAuth(引用System.Web.Mvc版本1.0.0.0).
I'm using DotNetOpenAuth (which references System.Web.Mvc version 1.0.0.0) in a Mvc 3.0.0.0 project in Visual Studio 2010.
我正在使用程序集绑定重定向,如下所示:-
I'm using assembly binding redirection as follows:-
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
一切正常,除了代码分析会给我以下错误:-
Everything works fine, except code analysis which gives me the following errors:-
CA0001:读取模块X时遇到以下错误:无法解析程序集引用:System.Web.Mvc,版本= 1.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35.
CA0001 : The following error was encountered while reading module X: Assembly reference cannot be resolved: System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
和
CA0058:找不到引用的程序集'System.Web.Mvc,版本= 1.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'.该程序集是分析所必需的,并被X引用.
CA0058 : The referenced assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be found. This assembly is required for analysis and was referenced by: X.
有没有办法让代码分析工具遵守程序集绑定重定向?
Is there a way to get the code analysis tool to respect the assembly binding redirection?
推荐答案
只需补充一点更精确的答案即可:
Just to supplement with a little more precise answer:
您需要使用以下命令运行FxCopCmd.exe:
You need to either run FxCopCmd.exe with:
fxcopcmd.exe /assemblyCompareMode:StrongNameIgnoringVersion
或为每个构建配置的属性组修改Visual Studio项目文件,如下所示:
or modify your Visual Studio project file for each build configuration's property group, like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
</PropertyGroup>
这篇关于程序集绑定重定向和代码分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!