locked
Error clicking "Product" route RRS feed

  • Question

  • User-1280648493 posted

    I have an application showing an error in the output when I click to open the "Product" route where it displays a list of all registered products, the following error only appeared after I registered the first product.

    Error:

    Microsoft.EntityFrameworkCore.Database.Command:Information: Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] SELECT [p].[Id], [p].[Ativo], [p].[DataCadastro], [p].[Descricao], [p].[FornecedorId], [p].[Imagem], [p].[Nome], [p].[Valor], [p.Fornecedor].[Id], [p.Fornecedor].[Ativo], [p.Fornecedor].[Documento], [p.Fornecedor].[Nome], [p.Fornecedor].[TipoFornecedor] FROM [Produtos] AS [p] INNER JOIN [Fornecedores] AS [p.Fornecedor] ON [p].[FornecedorId] = [p.Fornecedor].[Id] ORDER BY [p].[Nome] The program '[13392] iisexpress.exe' has exited with code -1073741819 (0xc0000005) 'Access violation

    can someone there help me?

    Link screen capture. here

    Wednesday, April 21, 2021 7:36 PM

All replies

  • User-474980206 posted

    it is really lis express crashing. you may need to use windbg to catch. If it is in your code, the most common cause is a stack overflow or unmanaged code that is called.

    Wednesday, April 21, 2021 9:59 PM
  • User-1280648493 posted

    code controller to index, 

    public async Task<IActionResult> Index()
            {
                return View(_mapper.Map<IEnumerable<ProdutoViewModel>>(await _produtoRepository.ObterProdutosFornecedores()));
            }

    ProdutoRepository

     public async Task<IEnumerable<Produto>> ObterProdutosFornecedores()
            {
                return await Db.Produtos.AsNoTracking().Include(f => f.Fornecedor)
                    .OrderBy(p => p.Nome).ToListAsync();
            }

    Wednesday, April 21, 2021 11:04 PM
  • User-474980206 posted

    probably _mapper uses reflection and does not detect a reference cycle, and is getting stack overflow or out of memory.

    Thursday, April 22, 2021 3:42 PM