none
no stackinformation after error RRS feed

  • Question

  • Hi,

    when an exception is thrown in a .NET Framework based program usually this dialog appears

    When click on Details button you get at least stackinformation to identify the function where the exception was thrown.

    But sometimes the program is terminated due to an error and this dialog appears

    What kind of error happens in this case, so that no stackinformation is available ?

    Can I configure something on the machine or in my program, so that also for this kind of error, stackinformation is available ?

    Monday, August 27, 2012 12:49 PM

Answers

  • "The question is, why does somethimes this dialog appear ... and other times the second one ??"

    The first dialog is displayed by WinForms when an exception is thrown but not handled in a UI thread, typically in some control even handler (Click, SelectionChanged...).

    The second dialog is displayed by the operating system when the application "crashes", that is, an exception is not handled by your code or by some framework code like WinForms. Typically this happens in non-WinForms applications or when the exception is thrown in a non-UI thread.

    Monday, August 27, 2012 7:03 PM
    Moderator

All replies

  • You need to add try/catch exception handlers into your routines to trap the errors.  Instead you are getting to the default handler which is visual Studio put into the root level of your application.  So when you are getting the exception you are going back to the root level of the program where there is no trace stack.  Addin gthe try/catch exception hanlders will create the error stack.

    jdweng

    Monday, August 27, 2012 12:59 PM
  • Hi Joel,

    well, of course if I add try/catch blocks into my application, I take care about the exceptions.

    But as you can read in the first snapshot, the dialog says "Unhandled exception has occured in your application". So this dialog was shown when an exception was thrown and my code DIDN'T catch it. The question is, why does somethimes this dialog appear although I didn't handle the exception myself, and other times the second one ??

    Any hint for this ?

    Monday, August 27, 2012 1:49 PM
  • In this situation I normall have to add break points and step through code to find out where the problem is occuring.  For some reason the error isn't in one of your exception handlers.


    jdweng

    Monday, August 27, 2012 3:02 PM
  • "The question is, why does somethimes this dialog appear ... and other times the second one ??"

    The first dialog is displayed by WinForms when an exception is thrown but not handled in a UI thread, typically in some control even handler (Click, SelectionChanged...).

    The second dialog is displayed by the operating system when the application "crashes", that is, an exception is not handled by your code or by some framework code like WinForms. Typically this happens in non-WinForms applications or when the exception is thrown in a non-UI thread.

    Monday, August 27, 2012 7:03 PM
    Moderator
  • The visual Studio Exception handler only traps errors on the Visual Studio execution stack.  If an eror is occuring on a diffferent stack Visual Studio will not capture these errors.  Some errors will not trap but you can test the return value to determine if they fail.  For example some windows calls wil return an error status that you must check.  If you don't check for these errors and continue executing it may cause an error like what you are seeing.

    Some reason for this is as follows

    1) If the Net Library function spawn a new process processes or calls an exe file

    2)  The Net library also uses dll in the system32 folder.  If an error occurs in these dlls they won't always get trapped by the Visual Studio exception handlers. 

    Note : You get the last error window error using a win32 API, but you need to test first if the function has failed.


    jdweng

    Monday, August 27, 2012 7:16 PM
  • Hi Fritz,

    Welcome to the MSDN Forum.

    How about Mike Danes and Joel's post?

    Do you have any update about this issue?

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 29, 2012 1:36 PM
    Moderator
  • Hi Mike,

    no, there are no further updates from my side.

    The best answer was from Mike Danes. His description, under what circumstances which dialog appears was sufficient for me.

    you can set this tread as answered

    regards

    Wednesday, August 29, 2012 1:44 PM
  • Hi Fritz,

    I got it.

    Thank you for your comfirmation.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 29, 2012 4:37 PM
    Moderator