InvalidOperationException:尝试激活

时间:2019-10-10 19:45:01

标签: asp.net

处理请求时发生未处理的异常。 InvalidOperationException:尝试激活“ Taste.Areas.Identity.Pages.Account.RegisterModel”时,无法解析类型为“ Microsoft.AspNetCore.Identity.UI.Services.IEmailSender”的服务。 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,bool isDefaultParameterRequired)

堆栈查询Cookie标头路由 InvalidOperationException:尝试激活“ Taste.Areas.Identity.Pages.Account.RegisterModel”时,无法解析类型为“ Microsoft.AspNetCore.Identity.UI.Services.IEmailSender”的服务。 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,bool isDefaultParameterRequired) lambda_method(Closure,IServiceProvider,object []) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageModelActivatorProvider + <> c__DisplayClass1_0.b__0(PageContext上下文) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageModelFactoryProvider + <> c__DisplayClass3_0.b__0(PageContext pageContext) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.CreateInstance() Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(下一个参考状态,参考作用域范围,参考对象状态,参考布尔值已完成) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited | 24_0(ResourceInvoker调用程序,Task lastTask,Next状态,Scope作用域,对象状态,bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed上下文) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(下一个参考状态,参考作用域范围,参考对象状态,参考布尔值已完成) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged | 17_1(ResourceInvoker调用程序) Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext上下文) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.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上下文)

处理请求时发生未处理的异常。 InvalidOperationException:尝试激活“ Taste.Areas.Identity.Pages.Account.RegisterModel”时,无法解析类型为“ Microsoft.AspNetCore.Identity.UI.Services.IEmailSender”的服务。 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,bool isDefaultParameterRequired)

堆栈查询Cookie标头路由 InvalidOperationException:尝试激活“ Taste.Areas.Identity.Pages.Account.RegisterModel”时,无法解析类型为“ Microsoft.AspNetCore.Identity.UI.Services.IEmailSender”的服务。 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,bool isDefaultParameterRequired) lambda_method(Closure,IServiceProvider,object []) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageModelActivatorProvider + <> c__DisplayClass1_0.b__0(PageContext上下文) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageModelFactoryProvider + <> c__DisplayClass3_0.b__0(PageContext pageContext) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.CreateInstance() Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(下一个参考状态,参考作用域范围,参考对象状态,参考布尔值已完成) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited | 24_0(ResourceInvoker调用程序,Task lastTask,Next状态,Scope作用域,对象状态,bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed上下文) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(下一个参考状态,参考作用域范围,参考对象状态,参考布尔值已完成) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged | 17_1(ResourceInvoker调用程序) Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext上下文) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.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上下文)

1 个答案:

答案 0 :(得分:0)

根据docs,您似乎不应该在 router.use(cookieParser()); router.use( session( { secret: 'keyboard cat', cookie: { maxAge: 24 * 60 * 60 * 1000 }, resave: true, saveUninitialized: false } ) ); router.use(passport.initialize()); router.use(passport.session()); 中使用IEmailSender

通常,该错误表示缺少依赖项,在您的情况下,该错误表示RegisterModel的实现。有关如何注册依赖项的信息,请参见docs