identityserver4.net-6.0

Migration To NET6


I tried to migrate my ASP CORE project to NET6 My project uses next packages

IdentityServer4.AccessTokenValidation - 3.0.1

IdentityModel.AspNetCore.OAuth2Introspection - 4.0.1

IdentityModel - 5.2.0

The build of project is success. But when I run application I get error

MissingMethodException: Method not found: 'IdentityModel.Client.DiscoveryEndpoint IdentityModel.Client.DiscoveryEndpoint.ParseUrl(System.String)'.
IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationOptions.ConfigureJwtBearer(JwtBearerOptions jwtOptions)
IdentityServer4.AccessTokenValidation.ConfigureInternalOptions.Configure(string name, JwtBearerOptions options)
Microsoft.Extensions.Options.OptionsFactory<TOptions>.Create(string name)
Microsoft.Extensions.Options.OptionsMonitor<TOptions>+<>c__DisplayClass10_0.<Get>b__0()

Anybody had this issue ?


Solution

  • I investigated this problem and found cause. I used IdentityModel V 4,2,2 before update. When I update my project to NET 6, IdentityModel was upgrated to version 5.2.0. The difference between IdentityModel V 4,2,2 and IdentityModel version 5.2.0 was in signature method.

    public static DiscoveryEndpoint ParseUrl(string input, string path = null) version 5,2,0
    public static DiscoveryEndpoint ParseUrl(string input) version 4,2,2
    

    So we see that in new version default parameter was added. But this method is called by method from IdentityServer4.AccessTokenValidation package. And this package was not compiled to call updated ParseUrl function.

    See this topic about this problem c# method with default parameter value does not generate overload without parameter?