Windows Forms application crash without any message

maxambrogi 6 Reputation points

I have developed a windows forms app to copy document from web repository to another one.
The application works fine but after 5 hours (and > 20k documents copied) it crash without any useful info.
For sure the copy code is inside a try/catch block .
I have also followed the info here:
and added the support for the large object: <configuration><runtime><gcAllowVeryLargeObjects enabled="true" /></runtime>.
The os is windows 10 and the .net framework is 4.7.2.


  1. how i can understand what happens ? there are insight from the OS or his event viewer??
  2. how i can update/make better my c# code to manage this situation?
  3. there are some best practice to follow?
  4. there is a way to intercept the kill of the process ?

Thanks and regards

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,388 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Michael Taylor 40,926 Reputation points

    Enabling large object support isn't needed here unless your code is not properly managing resources. You didn't post any relevant code so we have no way of knowing that.

    1. Ensure any IDisposable objects are being properly cleaned up.
    2. If you are connecting to a remote server using HttpClient then ensure you aren't creating new instances all the time or you will run out of resources.
    3. If the remote server requires authentication then, depending upon the authentication, your credentials may be expiring. You need to handle that case.
    4. Just because you're using try-catch doesn't mean you're actually handling the errors. This is a false assumption that people have. Without seeing your code we cannot say whether your try-catch is actually doing anything useful or not.
    5. Out of the box (without you changing the unhandled exception settings) then Winforms will automatically display a UI when an error occurs. Don't override this so you can see the UI message.
    6. Network communications are not reliable so it is possible your connection to the client is lost. Your code needs to handle reconnecting in this case.
    7. Event log should show any runtime error as should the Windows Error Reporting tool.
    8. Using Process Explorer to monitor your app while it is running will help indicate if you have a memory or resource leak which could bring the app down.
  2. maxambrogi 6 Reputation points

    @Michael Taylor ,thanks for the suggestions, i will check points 2) , 6) , 8).
    About point 7) how i can better understand what you mean? I haven't find any info in the event log.

  3. Olaf Helper 27,051 Reputation points

    how i can update/make better my c# code to manage this situation?

    How could we suggest without knowing any kind of detail about your implemention? You didn't provide any detail about it.
    Common issue is to "ignore" existing Dispose methods to release resources like memory.