locked
VB.NET Console Application random self-close on Windows Server 2012, 2016 without crash report RRS feed

  • Question

  • My .NET console application with try/catch covered to handle exceptions, no intention exit code while running,  has been tested and runs well on my Windows server 2008 for a month without issue. However when I run it on Windows Server 2012, 2016, i usually see the application auto random close after a few days.

    When I look at the Event Viewer, I don't see any application crash report. Near the time it close, i found this log:

    Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards. No user action is required.  

     DETAIL -
     2 user registry handles leaked from \Registry\User\S-1-5-21-89958827-396464871-1043300328-500_Classes:
    Process 724 (\Device\HarddiskVolume2\Windows\System32\svchost.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500_CLASSES
    Process 1868 (\Device\HarddiskVolume2\ConsoleApplication.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500_CLASSES


    ----

    Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards. No user action is required.  

     DETAIL -
     16 user registry handles leaked from \Registry\User\S-1-5-21-89958827-396464871-1043300328-500:
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500
    Process 724 (\Device\HarddiskVolume2\Windows\System32\svchost.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\Root
    Process 1868 (\Device\HarddiskVolume2\ConsoleApplication.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\Windows\CurrentVersion\Explorer
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\CA
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\TrustedPeople
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\SmartCardRoot
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Policies\Microsoft\SystemCertificates
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Policies\Microsoft\SystemCertificates
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Policies\Microsoft\SystemCertificates
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Policies\Microsoft\SystemCertificates
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\Disallowed
    Process 468 (\Device\HarddiskVolume2\Windows\System32\lsass.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500\Software\Microsoft\SystemCertificates\trust

    I checked again but my application doesn't have code to read/write those registry keys.  It's just a simple TCP server listening on a port with SSL enabled. Does that log provide the reason why my application self closes?


    • Edited by vuadapass Monday, May 4, 2020 11:24 AM
    Monday, May 4, 2020 11:22 AM

All replies

  • Well, it seems to me that you should be doing some activity event logging, like logging when a method is executed and when it ends in an attempt to find out at what point the program stops working.

    You could implement a global exception handler for the service.

    https://raygun.com/blog/windows-service-exception-handling/

    https://stackify.com/csharp-catch-all-exceptions/

    You can remove the try/catches in your code to make all exception unhandled caught by the GEH.

    Monday, May 4, 2020 3:31 PM
  • Thank you very much, I just forgot about it, let me try this
    Tuesday, May 5, 2020 9:26 AM
  • Hi vuadapass,

    How is the question going? If your question has been answered then please click the "Mark as Answer" Link at the bottom of the correct post(s), so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 6, 2020 9:11 AM
  • Hi all,

    I'm come back. I just launch my new app and waited few days to see if a global exception handle work.

    I use this code to handle all exceptions:  https://stackoverflow.com/questions/20368699/handling-exception-at-application-level  . I do a quick test and the code works well for recognize an exception.

    However, I surprise that this issue happen again, and I got no report. The software auto close again without any crash report and the global exception cannot handle it. Again, I got this event in Event Viewer near the time the application shutdown:

    Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards. No user action is required.  

     DETAIL -
     2 user registry handles leaked from \Registry\User\S-1-5-21-89958827-396464871-1043300328-500_Classes:
    Process 732 (\Device\HarddiskVolume2\Windows\System32\svchost.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500_CLASSES
    Process 1844 (\Device\HarddiskVolume2\Windows\ConsoleApplication.exe) has opened key \REGISTRY\USER\S-1-5-21-89958827-396464871-1043300328-500_CLASSES

    I'm using .NET Framework 4. May be it's a bug from .NET Framework or Windows?




    • Edited by vuadapass Friday, May 8, 2020 5:26 PM
    Friday, May 8, 2020 5:25 PM
  • Just becuase a program crashes does it mean an exception is going to be thrown.

    Why are you not doing some kind of debug logging some trace logging on activates in the code so you can at least find out what the program was doing when it went down?

    Do you even know what the program was doing when it crashed?

    https://aspnetjitendra.wordpress.com/2015/08/10/configure-log4net-for-vb-net-or-c-net/

    I doubt the .NET framework has some kind of bug.

     
    Friday, May 8, 2020 6:36 PM
  • Hi vuadapass,

    Thanks for your feedback.

    >>May be it's a bug from .NET Framework or Windows?

    In order to get more help about this issue, you can consider reporting a problem in Developer Community forum.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 11, 2020 7:02 AM