7

I receive the following two errors when I try to compile my MVC4 web project:

CA0058 Error Running Code Analysis CA0058 : The referenced assembly 'DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' could not be found. This assembly is required for analysis and was referenced by: C:\Users\bflynn\Visual Studio Sites\mnp\bin\mnp.dll, C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\Microsoft.Web.WebPages.OAuth.dll. [Errors and Warnings] (Global)

and

CA0001 Error Running Code Analysis CA0001 : The following error was encountered while reading module 'Microsoft.Web.WebPages.OAuth': Assembly reference cannot be resolved: DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246. [Errors and Warnings] (Global)

I recently added the DotNetOpenAuth.AspNet package to the application, and it seems tied to that. I have Cleaned, Rebuilt, Open/Closed the program, Uninstalled/Re-installed the package, yet the errors persists.

sharptooth
  • 167,383
  • 100
  • 513
  • 979
cardiac7
  • 491
  • 1
  • 9
  • 26

6 Answers6

5

I just ran into this too.

Don't upgrade DOA to 4.1

It looks like the aspnet dll has a specific version referenced. Altough it's .nuspec file says 4.0+ is ok...

Solution:

Uninstall-Package -Force each DotNetOpenAuth package (core /aspnet /oauth/openid etc)

Install-Package DotNetOpenAuth.AspNet -Version 4.0.4.12182

Remco Ros
  • 1,467
  • 15
  • 31
5

I used this to resolve the issue:

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
Jordy Langen
  • 3,591
  • 4
  • 23
  • 32
1

I ran into the same issue the other day and reported it http://aspnetwebstack.codeplex.com/workitem/443

Todd Carter
  • 879
  • 7
  • 20
0

Problem was reported on 21. september 2012. (http://aspnetwebstack.codeplex.com/workitem/443)

It was closed on 5. june 2013 with message:

The next version of MVC will not have a dependency on DotNetOpenAuth. Use the recommended workarounds below.

So I used the workaround https://stackoverflow.com/a/12847018/1016682

Community
  • 1
  • 1
Hubo
  • 161
  • 1
  • 11
0

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

See Yao's answer. The only solution I found that actually works for this.

Community
  • 1
  • 1
MC9000
  • 2,076
  • 7
  • 45
  • 80
0

I had the same issue. Though the code analysis issue got fixed, the web application wouldn't run because of the following error.

Could not load file or assembly 'DotNetOpenAuth.AspNet' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

It turned that the web.config was not cleaned as part of the uninstall. I had to remove the following dependentAssembly from web.config under the runtime/assemblyBinding section.

 <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>

The details can be read in http://www.bigcode.net/2013/07/error-running-code-analysis-in-vs2012.html

SanS
  • 385
  • 8
  • 21