Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net application crashes unexpected without exception

Tags:

.net

crash

I have a crashing .NET 2.0 application which does not give an exception or any other kind of message when the application crashes. I'm catching the Application.ThreadException event, and nothing is received when crashing. After running some days, the application is gone ! No message in the windows event log, no dump file or whatever.... I tried to run the application on several pc's, but after some days, the problem appears.

The application is communicating with another PC via TCP/IP connection, and all the data is valid all the time, no broken connections or whatever. There is enough memory, also at the time of crashing, etc. Disk space also no problem. There is no option to upgrade to .NET 4.0.

At this moment the application is running under windbg, so i hope this will give some info..

If you have any experience with this, or have some useful tips or tools, let me know !

like image 374
andy V Avatar asked Dec 15 '10 19:12

andy V


People also ask

How would you troubleshoot an application that crashes sporadically?

The easiest way to fix an app that keeps crashing on your Android smartphone is to simply force stop it and open it again. To do this, go to Settings -> Apps and select the app that keeps crashing. Tap on the app's name and then tap on 'Force stop'. Now try opening the app again and see if it works well.

What causes application crashes?

Apps on Android can crash because of low storage space, too many apps running simultaneously, a weak internet connection, or not having the proper app updates installed.

Why application crash in Android Studio?

Stay organized with collections Save and categorize content based on your preferences. An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.


4 Answers

If you use TCP/IP then you are quite likely using threads. If a thread dies with an unhandled exception, very common when calling EndXxxx(), then your app terminates. This may be silent if Windows Error Reporting is turned off on the machine, not uncommon on servers. At least catch ObjectDisposedException so you can deal with a connection that abruptly disconnects or is closed forcibly.

And yes, write an event handler for AppDomain.CurrentDomain.UnhandledException, subscribe it in your Main() method. Log or display the value of e.ExceptionObject.ToString() so you can tell exactly what it is dying on.

like image 164
Hans Passant Avatar answered Nov 05 '22 08:11

Hans Passant


When a .Net application suddenly exits without any error prompts or the unhandled exception handlers firing then it's very likely that your application is encountering a stack overflow. This will quickly terminate the process in many cases without running any handlers.

like image 29
JaredPar Avatar answered Nov 05 '22 08:11

JaredPar


Try AppDomain.UnhandledException. Application.ThreadException only raises when an exception occurs on the UI threads.

like image 30
Szymon Rozga Avatar answered Nov 05 '22 08:11

Szymon Rozga


I've had this issue.

I'd written a .Net application which was performing keystroke emulation on other applications. I'd leave it running all night hoping to find it having done all my work by the morning. It was just gone. It wrote a log every time it entered and exited a routine so I could see exactly what it had done. Nothing, no exception logging. Just work work work work work. And then, Nothing.

Turns out it was because I was using a bunch of API calls and I was calling them very frequently. This was causing some kind of memory leak, presumably in my application's workspace.

<dirtyhack> The way I resolved it was by writing another .Net application (application 2) which started up the crashing one (application 1). After so long application 1 would terminate itself but shell application 2 just before. Application 2 would then start application 1 back up. </dirtyhack>

and so on and so on, until all the work got done! Messy and frustrating but ended up working quite beautifully :) I'm sure there's a much much much better way of doing this. I was probably not marshaling my COM API calls properly or whatever.

But it seems that shutting the app down and restarting it was releasing the memory (along with the leaks) and letting it start afresh.

Perhaps no use in your cirsumstance but that's my story. Amen.

like image 24
El Ronnoco Avatar answered Nov 05 '22 09:11

El Ronnoco