How to capture Stackoverflowexception

Asked

Viewed 72 times

4

Hello,

I am going through some problems on the server and with the application developed in MVC...

I checked that the site was restarting the application pool alone, so I went to Event Viweer and noticed that the application is suffering Stackoverflowexception in some routine (which I could not map yet).

Right, knowing this I created a requests log to get the urls that accessed and so try to find the cause of the problem thrashing, However, I could not find the main cause, because even debugging the system by the localhost and pointing to the production bank does not occur this Stackoverflowexception. I write the log to a file . txt before entering each action (this is how I am trying to figure out the routine that is causing the problem).

I need to know a way to capture this exception and find out in which section of the system this problem is occurring.

OBS: • The application is developed in MVC. • Utiliza Automapper (I believe it has something to do, since I have to convert to a Viewmodel/DTO each object and display on the screen the information). • Is allocated to an IIS server

Update 01/06/2017

I used Elmah, but it didn’t work the way I created log, because the pool was falling, and I believe Elmah’s version was stored in memory. I discovered the problem when entering a system page locally and the application drops.

The reason for Stackoverflowexception was due to the fact of using two routing attributes in the same Controller`:

[RoutePrefix("exemplo")]
[Route("{action}"]
public class TesteController : Controller 
{
    ....
}

I removed the second attribute and the problem is gone.

The funny thing is that this configuration was already a long time before I even took over the project. I realized that it also happened randomly, because I was normally in all actions of this Controller.

  • "I believe it has something to do, since I have to convert to a Viewmodel/DTO each object and display on the screen the information". Why?

  • Good evening, in case the Automapper gave me some circular reference problems, so one entity ends up mapping another and generates the Overflow. Of course, it is not the Automapper itself that is the problem, but the way I should be using it. I have many mapped classes and I think it will be hard work to figure out which of these mappings is giving problem.

  • No, no. I asked why you need to "convert to a Viewmodel/DTO each object", because no need.

  • They use an internal system to generate the tables of the Database, also has a nomenclature in which each field should have less letters and ends up generating a great confusion. In addition, most fields in all tables are 'nullables'. Most tables have unused fields, so I only play the fields I need in View Models (although I can do this directly in the root entities). I chose to do it this way, I believe it was a mistake. I am waiting for the opportunity to reformulate this system, but this error has appeared and is priority fix it.

1 answer

5


A more efficient method to capture the exception (and the Stack Trace all) is using the ELMAH.

Also try to publish along with the system the file .pdb, so that you have in the messages captured from ELMAH the lines in which the errors occur within the source code.

  • 1

    Thanks man, I’ll check it out and take a look at it now.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.