Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. The located assembly's manifest definition does not match the assembly reference.

blah 6 Reputation points
2021-12-23T05:25:08.603+00:00

I recently upgraded Microsoft Owin 2.1.0 to 4.2.0.

Upon running in local my website has the below error.

I have checked the DLLs, its the latest 4.2.0.

LOG: DisplayName = Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)

Calling assembly : Microsoft.AspNet.SignalR.Core, Version=2.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:
FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.1.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)]
Owin.OwinExtensions.MapSignalR(IAppBuilder builder, String path, HubConfiguration configuration) +0
Owin.OwinExtensions.MapSignalR(IAppBuilder builder) +33

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +168
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +105
Owin.Loader.<>c_DisplayClass19_1.<MakeDelegate>b0(IAppBuilder builder) +66
Owin.Loader.<>cDisplayClass9_0.<LoadImplementation>b0(IAppBuilder builder) +123
Microsoft.Owin.Host.SystemWeb.<>cDisplayClass5_0.<InitializeBlueprint>b_0(IAppBuilder builder) +81
Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) +462 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +40
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +70
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +119
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +552
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +181
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +228
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +314

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10087352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263

Nugets which i have upgraded:

  • Newtonsoft.Json.13.0.1
  • Microsoft.Owin.Host.SystemWeb.4.2.0
  • Microsoft.Owin.Security.4.2.0
  • Microsoft.Owin.4.2.0
  • Owin.1.0
  • Microsoft.AspNet.SignalR.SystemWeb.2.4.2
  • Microsoft.AspNet.SignalR.Core.2.4.2
  • Microsoft.AspNet.SignalR.2.4.2
  • Microsoft.AspNet.SignalR.JS.2.4.2

I have checked the binding the web.config.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>

Reinstalled via the nuget. Still cant overcome the mentioned issue.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,246 questions
{count} votes

2 answers

Sort by: Most helpful
  1. blah 6 Reputation points
    2022-01-13T03:55:39.383+00:00

    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    Have to remove the xmlns to just <configuration> and it's working.

    1 person found this answer helpful.

  2. TK 6 Reputation points
    2024-02-15T01:14:13.16+00:00

    I removed my .vs folder and updated the newVersion redirect in the web.config to 4.2.2.
    <dependentAssembly> <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="4.2.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="4.2.2.0" /> </dependentAssembly>

    0 comments No comments