28

I have a fresh MVC5 project made from Visual Studio 2013, which works fine when I try to launch it locally. However, when I publish to my Azure website, I get this front page:

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

And the stack trace:

[FileLoadException: Could not load file or assembly 'Microsoft.Owin.Security.Cookies' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Microsoft.Owin.Security.Cookies, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, >Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Owin.Security.Cookies, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +736 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +284 System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Owin.Security.Cookies, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

I have version 3.0.0 of Microsoft.Owin installed, and it says the same thing in my Web.config and packages.config. How can I fix this?

1
  • 4
    Update-Package -ProjectName myproject Sep 25, 2015 at 8:11

2 Answers 2

89

Try to :

  1. Upgrading Microsoft.Owin.Security from 2.1.0 to 3.0.0
  2. Upgrading Microsoft.Owin.Security.Cookies from 2.1.0 to 3.0.0
  3. Upgrading Microsoft.Owin.Security.OAuth from 2.1.0 to 3.0.0

After I have upgraded above packages, the problem is resolved.

6
  • 3
    Yup, I figured this out a while ago and forgot about this question. Just reinstall whatever package it is asking for. Thanks for taking the time to answer!
    – yesman
    Dec 22, 2014 at 9:55
  • I had newer versions, same problem. Getting them all to the same version helped. Mar 6, 2015 at 18:31
  • Yep, worked for me, upgraded to version 3.0 and error disappear
    – Raffaeu
    Mar 21, 2015 at 11:17
  • how do we upgrade can someone provide link
    – shawn
    Nov 5, 2015 at 15:07
  • Late to the party but to upgrade, one way is to use the Package Manager Console. Type "update-package Microsoft.Owin.Security" (without the quotes) and the next two as listed above.
    – GeoffM
    Sep 9, 2016 at 5:17
1

You can do this by following way

  1. Navigate to tools -> NuGet Package Manager -> Manage NuGet Packages for Solution..
  2. In NuGet solutions click on the installed tab.
  3. On the search bar type Owin. You can see all Owin packages in there.
  4. Compare package versions in both NuGet solution and Web.Config file.
  5. Rename newVersion="x.x.x.x" in web config according to versions in Nuget solution.

Below versions must consider in both NuGet solution and Web.Config

Microsoft.Owin.Security
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security.Cookies
Microsoft.Owin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.