C# Blazor中的System.Aggregate异常是什么
最近,(3天前)我开始使用Blazor开发一个新项目——公交车预订应用程序。我在数据库中创建了两个表,并用外键将它们链接在一起。当我运行这个项目时,我被卡住了 不是看到我创建的界面,而是一条错误消息,如下所示:C# Blazor中的System.Aggregate异常是什么,c#,asp.net-core,C#,Asp.net Core,最近,(3天前)我开始使用Blazor开发一个新项目——公交车预订应用程序。我在数据库中创建了两个表,并用外键将它们链接在一起。当我运行这个项目时,我被卡住了 不是看到我创建的界面,而是一条错误消息,如下所示: System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsof
System.AggregateException: 'Some services are not able to be constructed
(Error while validating the service descriptor 'ServiceType:
Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory`1[Microsoft.AspNetC
ore.Identity.IdentityUser] Lifetime: Scoped ImplementationType:
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory`1[Microsoft.AspNetCo
re.Identity.IdentityUser]': Unable to resolve service for type
'BusBookingApp.Data.ApplicationDbContext' while attempting to activate
'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore`6[Microsoft.
AspNetCore.Identity.IdentityUser,BusBookingApp.Data.ApplicationDbContext,Syst
em.String,Microsoft.AspNetCore.Identity.IdentityUserClaim`1[System.String],Mi
crosoft.AspNetCore.Identity.IdentityUserLogin`1[System.String],Microsoft.AspN
etCore.Identity.IdentityUserToken`1[System.String]]'.) (Error while
validating the service descriptor 'ServiceType:
Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.Ide
ntityUser] Lifetime: Scoped ImplementationType:
Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.Ide
ntityUser]': Unable to resolve service for type
'BusBookingApp.Data.ApplicationDbContext' while attempting to activate
'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore`6[Microsoft.
AspNetCore.Identity.IdentityUser,BusBookingApp.Data.ApplicationDbContext,Syst
em.String,Microsoft.AspNetCore.Identity.IdentityUserClaim`1
请问,我能做些什么来解决这个问题 您应该共享引发异常的代码。否则很难帮助您。如果您收到此消息,则表示您使用了
.Wait()
或.Result
而不是Wait
。这应该首先解决。内部异常显示DI容器找不到BusBookingApp.Data.ApplicationDbContext
,这意味着它没有在Startup.cs中注册。你的Startup.cs
看起来像什么?引发此异常的代码是什么样子的?您是否忘了向AddDbContext注册DbContext?您是否可以共享Startup.cs?尝试如下方式注册ApplicationDbContext:services.AddDbContext(options=>options.UseSqlServer(Configuration.GetConnectionString(“DefaultConnection”)代码>请问,我如何在此平台上与您共享请求的文件(Startup.cs)?