TLDR: 将AutoMapper.Extensions.Microsoft.DependencyInjection
降级到8.1.1
,该版本依赖于AutoMapper (>= 10.1.1 && < 11.0.0)
https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/8.1.1
长答案:
我也遇到了类似的警告或错误,但是在安装NuGet AutoMapper
时出现了问题:
NU1608检测到包版本超出依赖约束:
Duende.IdentityServer.EntityFramework.Storage 5.2.0需要
AutoMapper (>= 10.0.0 && < 11.0.0),但已解析版本为AutoMapper 11.0.1。
你可能已经安装了NuGet Microsoft.AspNetCore.ApiAuthorization.IdentityServer
或类似的程序包。
https://www.nuget.org/packages/Microsoft.AspNetCore.ApiAuthorization.IdentityServer
如果您查看Microsoft.AspNetCore.ApiAuthorization.IdentityServer NuGet依赖项,您将看到:
- net6.0
- Duende.IdentityServer (>= 5.2.0)
- Duende.IdentityServer.AspNetIdentity (>= 5.2.0)
- Duende.IdentityServer.EntityFramework (>= 5.2.0)
- Duende.IdentityServer.EntityFramework.Storage (>= 5.2.0)
- Duende.IdentityServer.Storage (>= 5.2.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 6.0.5)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 6.0.5)
- Microsoft.AspNetCore.Identity.UI (>= 6.0.5)
- Microsoft.Extensions.Http (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.1)
您可以通过手动更新以下库来解决它:
- Duende.IdentityServer
- Duende.IdentityServer.AspNetIdentity
- Duende.IdentityServer.EntityFramework
- Duende.IdentityServer.EntityFramework.Storage
- Duende.IdentityServer.Storage
Duende.IdentityServer.EntityFramework.Storage 6.1.0 依赖以下内容,可修复您的错误:
- net6.0
- AutoMapper (>= 11.0.0 && < 12.0.0)
- Duende.IdentityServer.Storage (>= 6.1.0)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.0)
https://www.nuget.org/packages/Duende.IdentityServer.EntityFramework.Storage/
然而,运行代码时使用
endpoints.MapRazorPages();
可能会导致以下异常:
System.Reflection.ReflectionTypeLoadException:“无法加载所请求的一个或多个类型。程序集'Microsoft.AspNetCore.ApiAuthorization.IdentityServer, Version=6.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'中类型'Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationDbContext`1'的方法'get_ServerSideSessions'没有实现。”
我已经向Microsoft提出请求,要求他们更新
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
以与最新的
Duende.IdentityServer.EntityFramework.Storage
兼容,这将解决问题。
https://github.com/dotnet/aspnetcore/issues/41897
Duende.IdentityServer.EntityFramework.Storage
NuGet包的版本。 - Martin Costello