abp icon indicating copy to clipboard operation
abp copied to clipboard

An internal error occured during your request

Open doganc opened this issue 6 years ago • 4 comments

Hi, I have a problem with my Entities, i haven't get any record from Order, if i try with swagger or jscript these error occured.

Where is my fault? May be it's fault in my basic structure. Thanks

objesoft.aBP.testPrj2.order.getList({});

code: null
message: "An internal error occurred during your request!"
details: null
validationErrors: null


public class Order:AuditedAggregateRoot<int>
	{
    public string OrderNumber { get; set; }
    public DateTime OrderDate { get; set; }
    public string CustomerName { get; set; }
    public string CustomerAddress { get; set; }

    public virtual ICollection<OrderDetail> OrderDetails { get; set; } = new List<OrderDetail>();

    protected Order()
    {

    }

    public Order(int id, string orderNumber, DateTime orderDate, string customerName, string customerAddress,List<OrderDetail> orderDetails):base(id)
    {
        OrderNumber = orderNumber;
        OrderDate = orderDate;
        CustomerName = customerName;
        CustomerAddress = customerAddress;
        OrderDetails = orderDetails;

    }

	}

public class OrderDetail:Entity { [ForeignKey("MasterId")] public int MasterId { get; set; }

    public string ItemCode { get; set; }
    public string ItemName { get; set; }
    public double Quantity { get; set; }
    public double Price { get; set; }
    public double LineTotalPrice => Quantity * Price;
    public virtual Order Order { get; set; }

    protected OrderDetail()
    {

    }

    public OrderDetail(int id,string itemCode, string itemName, double quantity, double price, Order order):base(id)
    {
        ItemCode = itemCode;
        ItemName = itemName;
        Quantity = quantity;
        Price = price;
        Order = order;

    }
}

My Dto's are,

public class OrderDto: AuditedEntityDto { public string OrderNumber { get; set; } public DateTime OrderDate { get; set; } public string CustomerName { get; set; } public string CustomerAddress { get; set; }

    public virtual List<OrderDetailDto> OrderDetails { get; set; } = new List<OrderDetailDto>();
}

public class OrderDetailDto:EntityDto { public string ItemCode { get; set; } public string ItemName { get; set; } public double Quantity { get; set; } public double Price { get; set; } public int MasterId => 0;

}

doganc avatar Mar 09 '20 10:03 doganc

Hi @doganc,

Did you inspect your problem in debug mode?

cotur avatar Mar 09 '20 10:03 cotur

@doganc, when you run an application (HttpApi.Host), the Logs folder is created inside this project. You should see error in Logs.txt.

leonkosak avatar Mar 09 '20 18:03 leonkosak

hi, @leonkosak , I create a new single Entity (Not master-Detail) that name is Customer, I try same get operation and i get same error,

Thanks for your help.

My AutoMapper profile is

  CreateMap<Customer, CustomerDto>();
  CreateMap<AddOrUpdateCustomerDto, Customer>();


2020-03-09 23:39:52.806 +03:00 [INF] Request starting HTTP/2.0 GET https://localhost:44375/api/app/customer  
2020-03-09 23:39:52.812 +03:00 [INF] Executing endpoint 'Objesoft.ABP.TestPrj2.CustomerAppService.GetListAsync (Objesoft.ABP.TestPrj2.Application)'
2020-03-09 23:39:52.816 +03:00 [INF] Route matched with {action = "GetList", controller = "Customer", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Application.Dtos.PagedResultDto`1[Objesoft.ABP.TestPrj2.CustomerDto]] GetListAsync(Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto) on controller Objesoft.ABP.TestPrj2.CustomerAppService (Objesoft.ABP.TestPrj2.Application).
2020-03-09 23:39:52.832 +03:00 [ERR] ---------- RemoteServiceErrorInfo ----------
2020-03-09 23:39:52.834 +03:00 [ERR] {
  "code": null,
  "message": "An internal error occurred during your request!",
  "details": null,
  "validationErrors": null
}
2020-03-09 23:39:52.835 +03:00 [ERR] An exception was thrown while activating Castle.Proxies.CustomerAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.CustomerAppServiceProxy.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.CustomerAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[Objesoft.ABP.TestPrj2.Customer,System.Int32] repository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[Objesoft.ABP.TestPrj2.Customer,System.Int32])'.
   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.Execute(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 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-03-09 23:39:52.838 +03:00 [ERR] ---------- Exception Data ----------
2020-03-09 23:39:52.838 +03:00 [ERR] ActivatorChain = Castle.Proxies.CustomerAppServiceProxy
2020-03-09 23:39:52.854 +03:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
2020-03-09 23:39:52.862 +03:00 [INF] Executed action Objesoft.ABP.TestPrj2.CustomerAppService.GetListAsync (Objesoft.ABP.TestPrj2.Application) in 45.8403ms
2020-03-09 23:39:52.862 +03:00 [INF] Executed endpoint 'Objesoft.ABP.TestPrj2.CustomerAppService.GetListAsync (Objesoft.ABP.TestPrj2.Application)'
2020-03-09 23:39:52.862 +03:00 [INF] Request finished in 56.1385ms 500 application/json; charset=utf-8

doganc avatar Mar 09 '20 20:03 doganc

Hi, @cotur , @leonkosak Again my mistake, I found the problem, I forget set to DbSet properties. The problem was solved. Thanks for your help

doganc avatar Mar 09 '20 21:03 doganc