Failed to load Microsoft.Owin.Security.OAuth file or assembly, Version = 2.0.0.0

I have an MVA project with OAuth authentication, every time I try to debug the project, I get a FileLoadException when setting IAppBuilder. I installed version 3.0.1 from Microsoft.Owin.Security.Oauth using PMC, but I think that somewhere else there is a link to an older version of the package, because ...

This is an exception:

enter image description here

Here it is thrown:

public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); //Exception is thrown here } } 

This is my package.config:

 <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Antlr" version="3.4.1.9004" targetFramework="net45" /> <package id="CommonServiceLocator" version="1.3" targetFramework="net45" /> <package id="EntityFramework" version="6.0.0" targetFramework="net45" /> <package id="jQuery" version="1.10.2" targetFramework="net45" /> <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" /> <package id="log4net" version="2.0.3" targetFramework="net45" /> <package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" /> <package id="Microsoft.AspNet.Web.Optimization" version="1.1.1" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi.Owin" version="5.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" /> <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.0.0" targetFramework="net45" /> <package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net45" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" /> <package id="Modernizr" version="2.6.2" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Owin" version="1.0" targetFramework="net45" /> <package id="Unity" version="3.5.1404.0" targetFramework="net45" /> <package id="WebGrease" version="1.6.0" targetFramework="net45" /> </packages> 

I tried to add call forwarding redirects as such:

 <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Security.OAuth" PublicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/> </dependentAssembly> 

I don’t understand why this does not work, does Visual Studio make a difference between 3.0.1 and 3.0.1.0?

I tried to delete the obj and bin folders, clean up the projects and restore them.

I tried to remove all nuget packages and restore them.

I tried reinstalling all Owin packages.

I used the Ransack agent to search my entire source directory for any file containing Microsoft.Owin.Security.OAuth, but could not find links to version 2.0.0.0 or any other version than the correct 3.0.1.0.

I'm stuck, any ideas?

+5
source share
2 answers

Good, so just in case, someone else will handle this problem;

The problem was that the Microsoft.AspNet.Identity.Owin package is dependent on Microsoft.Owin.Security.OAuth , and there is a mismatch in the version.

  <package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" /> 

Apparently, although Microsoft.AspNet.Identity.Owin requires> = v2.0 from Microsoft.Owin.Security.OAuth , having v3 + of Microsoft.Owin.Security.OAuth will break compatibility (inconsistency in the main version).

After I updated the package Microsoft.AspNet.Identity.Owin and its neighboring members of the Microsoft.AspNet.Identity.EntityFramework and Microsoft.AspNet.Identity.Core family, I removed all the packages, bin and obj folders and restored the solution. Voila!

Advice for VS2013 + Ultimate user should use the NuGet Visualizer when examining package dependencies.

+10
source

Check your recommendations. Remove Microsoft.Owin.Security.OAuth everywhere, then restore all nuget packages.

0
source

All Articles