abp icon indicating copy to clipboard operation
abp copied to clipboard

ASP.NET Core MVC Tutorial -- Debugging

Open samquest opened this issue 6 years ago • 3 comments

I am following this tutorial and getting An internal error occurred during your request! while executing this JavaScript (given in the tutorial) in the console

acme.bookStore.book.getList({}).done(function (result) { console.log(result); });

this is the js console

acme.bookStore.book.getList({}).done(function (result) { console.log(result); });
Object { notify: tuple[0](), notifyWith: fireWith(), resolve: tuple[0](), resolveWith: fireWith(), reject: tuple[0](), rejectWith: fireWith(), state: state(), always: always(), catch: catch(), pipe: pipe()
, … }

This site uses a deprecated version of TLS that will be disabled in March 2020. Please upgrade to TLS 1.2 or 1.3.
book
ERROR: abp.js:44:17
{…}
​
code: null​
details: null​
message: "An internal error occurred during your request!"​
validationErrors: null​
<prototype>: Object { … }

I tried debugging by overriding GetListAsync here


 public class BookAppService :
        CrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto,
                       CreateUpdateBookDto, CreateUpdateBookDto>,
        IBookAppService
    {
        public BookAppService(IRepository<Book, Guid> repository)
            : base(repository)
        {

        }

        public override Task<PagedResultDto<BookDto>> GetListAsync(PagedAndSortedResultRequestDto input)
        {
            return base.GetListAsync(input);
        }
    }

the debugger does not catch this and the error seem to be thrown even before this which is mentions as automagic. now how do i debug this?

And the UI presents the same message An internal error occurred during your request! as an alert.

samquest avatar Jan 15 '20 06:01 samquest

An internal error occurred during your request

Please check the applcation log file.

maliming avatar Jan 15 '20 06:01 maliming

i guess these are the relevant logs, looks like its not able to resolve the Repository.


2020-01-15 15:56:10.154 +09:00 [INF] Request starting HTTP/1.1 GET https://localhost:44378/api/app/book application/json 
2020-01-15 15:56:10.154 +09:00 [INF] Executing endpoint 'Acme.BookStore.BookAppService.GetListAsync (Acme.BookStore.Application)'
2020-01-15 15:56:10.169 +09:00 [INF] Route matched with {action = "GetList", controller = "Book", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Application.Dtos.PagedResultDto`1[Acme.BookStore.BookDto]] GetListAsync(Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto) on controller Acme.BookStore.BookAppService (Acme.BookStore.Application).
2020-01-15 15:56:10.169 +09:00 [ERR] ---------- RemoteServiceErrorInfo ----------
2020-01-15 15:56:10.169 +09:00 [ERR] {
  "code": null,
  "message": "An internal error occurred during your request!",
  "details": null,
  "validationErrors": null
}
2020-01-15 15:56:10.169 +09:00 [ERR] An exception was thrown while activating Castle.Proxies.BookAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.BookAppServiceProxy.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.BookAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[Acme.BookStore.Book,System.Guid] repository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[Acme.BookStore.Book,System.Guid])'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
   at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2020-01-15 15:56:10.169 +09:00 [ERR] ---------- Exception Data ----------
2020-01-15 15:56:10.169 +09:00 [ERR] ActivatorChain = Castle.Proxies.BookAppServiceProxy
2020-01-15 15:56:10.185 +09:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
2020-01-15 15:56:10.201 +09:00 [INF] Executed action Acme.BookStore.BookAppService.GetListAsync (Acme.BookStore.Application) in 38.5732ms
2020-01-15 15:56:10.201 +09:00 [INF] Executed endpoint 'Acme.BookStore.BookAppService.GetListAsync (Acme.BookStore.Application)'
2020-01-15 15:56:10.201 +09:00 [INF] Request finished in 47.6788ms 500 application/json; charset=utf-8

samquest avatar Jan 15 '20 07:01 samquest

Found the issue, I seemed to missed a step

public class BookStoreDbContext : AbpDbContext<BookStoreDbContext>
    {
        public DbSet<Book> Books { get; set; }
		...
    }

Thanks!

samquest avatar Jan 15 '20 07:01 samquest