在VS2012中运行代码分析时出错

时间:2012-09-25 17:56:39

标签: asp.net-mvc-4 visual-studio-2012 oauth code-analysis

当我尝试编译MVC4 Web项目时,我收到以下两个错误:

  

CA0058运行代码分析时出错CA0058:找不到引用的程序集“DotNetOpenAuth.AspNet,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 2780ccd10d57b246”。此程序集是分析所必需的,并通过以下方式引用:C:\ Users \ bflynn \ Visual Studio Sites \ mnp \ bin \ mnp.dll,C:\ Program Files(x86)\ Microsoft ASP.NET \ ASP.NET Web Pages \ 2.0 \组件\ Microsoft.Web.WebPages.OAuth.dll。 [错误和警告](全球)

  

CA0001错误运行代码分析CA0001:读取模块“Microsoft.Web.WebPages.OAuth”时遇到以下错误:无法解析程序集引用:DotNetOpenAuth.AspNet,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 2780ccd10d57b246。 [错误和警告](全球)

我最近将DotNetOpenAuth.AspNet包添加到应用程序中,它似乎与此相关。我已经清理,重建,打开/关闭程序,卸载/重新安装了程序包,但错误仍然存​​在。

6 个答案:

答案 0 :(得分:5)

我也碰到了这个。

不要将DOA升级到4.1

看起来aspnet dll引用了特定版本。尽管如此.nuspec文件说4.0+还可以......

解决方案:

Uninstall-Package -Force每个DotNetOpenAuth包(core / aspnet / oauth / openid等)

安装包DotNetOpenAuth.AspNet -Version 4.0.4.12182

答案 1 :(得分:5)

我用这个解决了这个问题:

1. Uninstall-Package Microsoft.AspNet.WebPages.OAuth –RemoveDependencies
2. Install-Package DotNetOpenAuth.AspNet -Version 4.0.4.12182
3. Install-Package Microsoft.AspNet.WebPages.OAuth

答案 2 :(得分:1)

前几天我遇到了同样的问题并报告了http://aspnetwebstack.codeplex.com/workitem/443

答案 3 :(得分:0)

2012年9月21日报告了问题。(http://aspnetwebstack.codeplex.com/workitem/443

2013年6月5日关闭,消息:

  

下一版MVC不会依赖DotNetOpenAuth。使用下面推荐的解决方法。

所以我使用了解决方法https://stackoverflow.com/a/12847018/1016682

答案 4 :(得分:0)

Code Analysis error Could not load file or assembly 'System.Net.Http, Version=2.0.0.0 in MVC4 Web API

看到姚明的回答。我找到的唯一解决方案实际上适用于此。

答案 5 :(得分:0)

我有同样的问题。虽然代码分析问题得到修复,但由于以下错误,Web应用程序无法运行。

无法加载文件或程序集“DotNetOpenAuth.AspNet”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)

它转变为web.config未作为卸载的一部分进行清理。 我必须从运行时/ assemblyBinding部分下的web.config中删除以下dependentAssembly。

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

详情可在http://www.bigcode.net/2013/07/error-running-code-analysis-in-vs2012.html

中阅读