实际上的Abp应用,大部分是前后端分离的. 对于自己开发的MVC的程序,大多数在controller里打断点, 单步调试就能找到问题了.
但ABP的程序,比如对数据库的查询都是用仓储类IRepository,
例如GetListAsync出错了
引用的dll出了错,没法单步调试
public async Task<List<TodoItemDto>> GetListAsync() { var items = await _todoItemRepository.GetListAsync(); //entity=> Dto return items.Select(item => new TodoItemDto { Id = item.Id, Text = item.Text }).ToList(); }
应对方法: 浏览器F12开发者工具,看一下错误信息, 好像没帮助
直接访问 url 的Get方法, 错误信息隐藏起来了.
查看服务端的log, 路径在HttpApi.Host\Logs
对应的log内容就很清晰了
2021-11-15 13:35:09.471 +08:00 [INF] Request starting HTTP/1.1 OPTIONS https://localhost:44338/api/app/todo?api-version=1.0 - - 2021-11-15 13:35:09.472 +08:00 [INF] CORS policy execution successful. 2021-11-15 13:35:09.472 +08:00 [INF] Request finished HTTP/1.1 OPTIONS https://localhost:44338/api/app/todo?api-version=1.0 - - - 204 - - 0.8472ms 2021-11-15 13:35:09.475 +08:00 [INF] Request starting HTTP/1.1 GET https://localhost:44338/api/app/todo?api-version=1.0 - - 2021-11-15 13:35:09.476 +08:00 [INF] CORS policy execution successful. 2021-11-15 13:35:09.478 +08:00 [DBG] CORS request made for path: /api/app/todo from origin: https://localhost:44307 but was ignored because path was not for an allowed IdentityServer CORS endpoint 2021-11-15 13:35:09.478 +08:00 [INF] No CORS policy found for the specified request. 2021-11-15 13:35:09.479 +08:00 [INF] Executing endpoint 'MetaBase.Platform.TodoAppService.GetListAsync (MetaBase.Platform.Application)' 2021-11-15 13:35:09.479 +08:00 [INF] Route matched with {action = "GetList", controller = "Todo", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[System.Collections.Generic.List`1[MetaBase.Platform.TodoItemDto]] GetListAsync() on controller MetaBase.Platform.TodoAppService (MetaBase.Platform.Application). 2021-11-15 13:35:17.465 +08:00 [ERR] Failed executing DbCommand (65ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30'] SELECT [a].[Id], [a].[Text] FROM [AppTodoItems] AS [a] 2021-11-15 13:35:17.466 +08:00 [ERR] An exception occurred while iterating over the results of a query for context type 'MetaBase.Platform.EntityFrameworkCore.PlatformDbContext'. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AppTodoItems'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() ClientConnectionId:3aaa92fd-0a8b-4802-93fd-b0b8f1fbd210 Error Number:208,State:1,Class:16 Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AppTodoItems'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.GetListAsync(Boolean includeDetails, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at MetaBase.Platform.TodoAppService.GetListAsync() in D:\terrywork\Metabase\aspnet-core\src\MetaBase.Platform.Application\TodoAppService.cs:line 42 ClientConnectionId:3aaa92fd-0a8b-4802-93fd-b0b8f1fbd210 Error Number:208,State:1,Class:16 2021-11-15 13:35:17.619 +08:00 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": { "HelpLink.ProdName": "Microsoft SQL Server", "HelpLink.ProdVer": "12.00.2000", "HelpLink.EvtSrc": "MSSQLServer", "HelpLink.EvtID": "208", "HelpLink.BaseHelpUrl": "https://go.microsoft.com/fwlink", "HelpLink.LinkId": "20476" }, "validationErrors": null } 2021-11-15 13:35:17.619 +08:00 [ERR] Invalid object name 'AppTodoItems'. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AppTodoItems'. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.GetListAsync(Boolean includeDetails, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at MetaBase.Platform.TodoAppService.GetListAsync() in D:\terrywork\Metabase\aspnet-core\src\MetaBase.Platform.Application\TodoAppService.cs:line 42 at lambda_method2775(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) ClientConnectionId:3aaa92fd-0a8b-4802-93fd-b0b8f1fbd210 Error Number:208,State:1,Class:16 2021-11-15 13:35:17.619 +08:00 [ERR] ---------- Exception Data ---------- HelpLink.ProdName = Microsoft SQL Server HelpLink.ProdVer = 12.00.2000 HelpLink.EvtSrc = MSSQLServer HelpLink.EvtID = 208 HelpLink.BaseHelpUrl = https://go.microsoft.com/fwlink HelpLink.LinkId = 20476 2021-11-15 13:35:17.619 +08:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'. 2021-11-15 13:35:17.619 +08:00 [INF] Executed action MetaBase.Platform.TodoAppService.GetListAsync (MetaBase.Platform.Application) in 8139.8869ms 2021-11-15 13:35:17.620 +08:00 [INF] Executed endpoint 'MetaBase.Platform.TodoAppService.GetListAsync (MetaBase.Platform.Application)' 2021-11-15 13:35:17.731 +08:00 [DBG] Added 0 entity changes to the current audit log 2021-11-15 13:35:17.731 +08:00 [DBG] Added 0 entity changes to the current audit log 2021-11-15 13:35:17.732 +08:00 [INF] Request finished HTTP/1.1 GET https://localhost:44338/api/app/todo?api-version=1.0 - - - 500 - application/json;+charset=utf-8 8255.8539ms
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?