Search code examples
asp.net-coreidentityserver4

TypeLoadException exception on signout after upgrading to aspnet core 3.1


I use IdentityServer4 for auth which gets installed with Asp.net core web project in visual studio 2019. After upgrading to asp.net 3.1, I get below error on SignOut. I tried force update all the Nugets to latest. Still, I couldn't make it work. Appreciate any workaround.

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.IReadableStringCollectionExtensions' from assembly 'IdentityServer4, Version=3.1.0.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b'.
Microsoft.AspNetCore.ApiAuthorization.IdentityServer.AutoRedirectEndSessionEndpoint.GetParametersAsync(HttpRequest request)
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder<TResult>.Start<TStateMachine>(ref TStateMachine stateMachine)
Microsoft.AspNetCore.ApiAuthorization.IdentityServer.AutoRedirectEndSessionEndpoint.GetParametersAsync(HttpRequest request)
Microsoft.AspNetCore.ApiAuthorization.IdentityServer.AutoRedirectEndSessionEndpoint.ProcessAsync(HttpContext ctx)
IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Solution

  • I fixed this by reverting the IdentityServer4.EntityFramework reference from version 3.1.0 to 3.0.2, it would seem that the missing type is not yet implemented in 3.1.0.

    I spent a few days researching this for work and I was unable to find any official documentation with regards to the problem or to the missing type. So the solution came from exasperation more than anything else. I apologize that I cannot provide you with adequate reasoning as to why it needs to be reverted, just that by doing it I fixed it.