Identityserver4的自动映射器问题-MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)' [英] Automapper issue with identityserver4 - MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'
问题描述
我使用的是IdentityServer 4的最新版本
问题/重现问题的步骤
- 创建一个新的blazor webassembly应用
- 我搭建了所有的身份文件并对其进行了自定义
- 和自定义ApiAuthorizationDbContext 用于出色的webassembly
- 安装
Automapper v10
和AutoMapper.Extensions.Microsoft.DependencyIn v8.0.1
当我运行项目时,浏览器中出现500错误:
以及在自托管控制台中: 和 堆栈: 显示原始异常详细信息 请勿后退,请勿降级,升级 似乎AutoMapper 此版本是非常新的版本,已在此答案日期前4天发布. I using last version of IdentityServer 4 when I run project, in-browser give me 500 error : and in self-host console: and in Stack: Show raw exception details
Do not move backward, Do not downgrade, Upgrade It seems that the AutoMapper This version is very new, it released 4 days before the date of this answer. 这篇关于Identityserver4的自动映射器问题-MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! AuthenticationService.js:44 GET https://localhost:5001/connect/authorize?client_id = Web.Client& redirect_uri = https%3A%2F%2Flocalhost%3A5001%2Fauthentication%2Flogin-callback& response_type =code& scope = Web.ServerAPI%20openid%20profile& state = 4b9b0120a48442a786b5bc8260c52f65& code_challenge = ViBkoIwumlfy_kg_y0bAh9uFsEByt2aKDOVUSREfARE& code_challenge_mp =& code_tall_method = samp;&n = code_challenge_meth ==& code_challenge_meth ==&&nb; code_challenge& p; mp_n = 500
暴击:IdentityServer4.Hosting.IdentityServerMiddleware [0]未处理的异常:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.System.MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.在IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant模型)在IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant令牌)处在IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key,T item,String clientId,String subjectId,创建的DateTime,Nullable`1到期)在IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item,字符串clientId,字符串subjectId,创建的DateTime,Int32生存期)在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)处在IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext上下文)处在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)失败:Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware [1]执行请求时发生未处理的异常.System.MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.在IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant模型)在IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant令牌)处在IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key,T item,String clientId,String subjectId,创建的DateTime,Nullable`1到期)在IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item,字符串clientId,字符串subjectId,创建的DateTime,Int32生存期)在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)处在IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext上下文)处在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)在IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke处(HttpContext上下文,IAuthenticationSchemeProvider方案)在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)在IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)在Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext上下文)
https://localhost:5001/connect/authorize?client_id = Web.Client& redirect_uri = https%3A%2F%2Flocalhost%3A5001%2Fauthentication%2Flogin-callback& response_type = code& scope =Web.ServerAPI%20openid%20profile& state = 4b9b0120a48442a786b5bc8260c52f65& code_challenge = ViBkoIwumlfy_kg_y0bAh9uFsEByt2aKDOVUSREfARE& code_challenge_method = S256& promp
在处理请求时发生未处理的异常.MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant模型)
MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant模型)IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant令牌)IdentityServer4.Stores.DefaultGrantStore< T> .StoreItemAsync(字符串键,T项目,字符串clientId,字符串subjectId,创建的DateTime,Nullable< DateTime>到期)IdentityServer4.Stores.DefaultGrantStore< T> .CreateItemAsync(T项目,字符串clientId,字符串subjectId,创建的DateTime,int生命周期)IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest请求)IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext上下文)IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext上下文,IAuthenticationSchemeProvider方案)Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext上下文)Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext上下文)Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext上下文)Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext上下文)Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext上下文)
System.MissingMethodException:找不到方法:'!! 0 AutoMapper.IMapper.Map(System.Object)'.在IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant模型)在IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant令牌)处在IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key,T item,String clientId,String subjectId,创建的DateTime,Nullable`1到期)在IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item,字符串clientId,字符串subjectId,创建的DateTime,Int32生存期)在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)处在IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)处在IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext上下文)处在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件)在IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke处(HttpContext上下文,IAuthenticationSchemeProvider方案)在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)在IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext上下文)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)在Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext上下文)
10.0.0
有一个错误,解决该问题的方法是将AutoMapper升级到 10.1.1
版本.Issue / Steps to reproduce the problem
Automapper v10
and AutoMapper.Extensions.Microsoft.DependencyIn v8.0.1
AuthenticationService.js:44 GET https://localhost:5001/connect/authorize?client_id=Web.Client&redirect_uri=https%3A%2F%2Flocalhost%3A5001%2Fauthentication%2Flogin-callback&response_type=code&scope=Web.ServerAPI%20openid%20profile&state=4b9b0120a48442a786b5bc8260c52f65&code_challenge=ViBkoIwumlfy_kg_y0bAh9uFsEByt2aKDOVUSREfARE&code_challenge_method=S256&prompt=none&response_mode=query 500
crit: IdentityServer4.Hosting.IdentityServerMiddleware[0]
Unhandled exception: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
at IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
at IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant token)
at IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key, T item, String clientId, String subjectId, DateTime created, Nullable`1 expiration)
at IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item, String clientId, String subjectId, DateTime created, Int32 lifetime)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, ConsentResponse consent)
at IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
at IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
at IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant token)
at IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key, T item, String clientId, String subjectId, DateTime created, Nullable`1 expiration)
at IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item, String clientId, String subjectId, DateTime created, Int32 lifetime)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, ConsentResponse consent)
at IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
https://localhost:5001/connect/authorize?client_id=Web.Client&redirect_uri=https%3A%2F%2Flocalhost%3A5001%2Fauthentication%2Flogin-callback&response_type=code&scope=Web.ServerAPI%20openid%20profile&state=4b9b0120a48442a786b5bc8260c52f65&code_challenge=ViBkoIwumlfy_kg_y0bAh9uFsEByt2aKDOVUSREfARE&code_challenge_method=S256&prompt=none&response_mode=query
file:An unhandled exception occurred while processing the request.
MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant token)
IdentityServer4.Stores.DefaultGrantStore<T>.StoreItemAsync(string key, T item, string clientId, string subjectId, DateTime created, Nullable<DateTime> expiration)
IdentityServer4.Stores.DefaultGrantStore<T>.CreateItemAsync(T item, string clientId, string subjectId, DateTime created, int lifetime)
IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest request)
IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, ConsentResponse consent)
IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext context)
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.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.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)
System.MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'.
at IdentityServer4.EntityFramework.Mappers.PersistedGrantMappers.ToEntity(PersistedGrant model)
at IdentityServer4.EntityFramework.Stores.PersistedGrantStore.StoreAsync(PersistedGrant token)
at IdentityServer4.Stores.DefaultGrantStore`1.StoreItemAsync(String key, T item, String clientId, String subjectId, DateTime created, Nullable`1 expiration)
at IdentityServer4.Stores.DefaultGrantStore`1.CreateItemAsync(T item, String clientId, String subjectId, DateTime created, Int32 lifetime)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest request)
at IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, ConsentResponse consent)
at IdentityServer4.Endpoints.AuthorizeEndpoint.ProcessAsync(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
10.0.0
has a bug, the solution to that problem was to upgrade AutoMapper to 10.1.1
version.