1

I have had this problem for a while now, and have talked to Microsoft about it, with no solution so far. Now I have reproduced the error in a brand new project. I have removed all unnessary code, and this code is still giving me the error:

System.StackOverflowException occurred
  HResult=0x800703E9
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

My project consists of a Startup.cs class with this content:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<FrilivDB>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")).EnableSensitiveDataLogging());
        services.AddMvc();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseMvc(routes =>
        {
            routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
            routes.MapRoute("ViewProduct", "{brand}/{productTitle}", defaults: new { controller = "Products", action = "Details" });
        });
    }
}

My Productscontroller looks like this:

public class ProductsController : Controller
{
    private readonly FrilivDB _context;

    public ProductsController(FrilivDB context)
    {
        _context = context;
    }

    public async Task<IActionResult> Details(string brand, string productTitle)
    {
        var product = _context.Products.Select(p => p.Title);
        return View();
    }
}

And when passing by this line in the debugger the error occurs:

var product = _context.Products.Select(p => p.Title);

The error occurs after waiting between 15 and 30 seconds, every time. Any one has any ideas or experienced the same thing?

This is what I see in the Output window:

    AO.Shop>       Request starting HTTP/1.1 GET http://localhost:44317/tatonka/alaska  
AO.Shop> info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
AO.Shop>       Request starting HTTP/1.1 GET http://localhost:44317/tatonka/alaska  
AO.Shop> info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
AO.Shop>       Executing action method AO.Shop.Controllers.ProductsController.Details (AO.Shop) with arguments (tatonka, alaska) - ModelState is Valid
AO.Shop> info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
AO.Shop>       Executing action method AO.Shop.Controllers.ProductsController.Details (AO.Shop) with arguments (tatonka, alaska) - ModelState is Valid
AO.Shop> 
AO.Shop> Process is terminating due to StackOverflowException.
1
  • This is what I see in the Output window: ´´` Commented Sep 12, 2017 at 5:30

2 Answers 2

4

After a lot of comminication with Microsoft and a whole lot of debugging and commenting code in and out, I found the problem.

It was due to poor DB settings. I had 4 tables in my DB which were referencing them selves as Foreign keys, that gave a Stackoverflow Exception from the EF Core.

After removing all 4 and rebuilding the entire Model, it worked. Thanks for your input

Sign up to request clarification or add additional context in comments.

Comments

-1

Add one or more try-catch statements to get more information about the exception being generated. Then use that information to update your code to prevent the exception from occurring.

Also, consider reviewing the patches that Microsoft has for ASP.NET 2.0. This ASP.NET 2.0 hotfix rollup package page references some issues that may apply to your problem. Another option is to upgrade to ASP.NET 3.5+, but I presume that you are trying to avoid that approach.

I hope this helps.

2 Comments

This is more of a comment then an answer, as such you should move it to the comments section
I have tried that, it is not catched by any try catch. Did I mention that Microsoft has not yet found a solution for this. Somehow the error might occur in msvsmon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.