locked
JIT Debugging RRS feed

  • Question

  • Ok im still new to this but how in the world do i enable JIT debugging on my windows form application and where do i do it.

    i have the following code

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    But i place it in my form but it doesn't work anyone know what i should do or where i should place it ???
    Monday, June 27, 2005 10:13 AM

Answers

  • Hi,

    I think things have changed with Beta2. Did some R&D and finally out how to do this in VB 2005 and Beta 2. Here are the steps:

    To manage an unhandled exception
    1. With a project selected in Solution Explorer, from the Project menu select Properties.

    2. Select the Application tab.

    3. Click the View Code button to open the Code Editor.

    4. This opens the MyEvents.vb file.

    5. With the MyEvents.vb file open in the Code Editor, from the General drop-down menu select MyApplication Events.

    6. From the Declarations drop-down menu, select UnhandledException.

    7. The application raises the UnhandledException event before the main application runs.

    8. Add code or MessageBox there which will display ur user friendly message.

    Regards,
    Vikram

     

    Tuesday, July 5, 2005 12:02 PM

All replies

  • Anyone that knows the answer ???
    Tuesday, June 28, 2005 6:50 PM
  • That didn't help much i still don't know what code to use how to turn it on in my windows forms.
    Tuesday, June 28, 2005 9:55 PM
  • Does anyone know the answer ??
    Thursday, June 30, 2005 9:35 AM
  • I cant believe no one here knows an answer or is able to help me with this problem.
    Friday, July 1, 2005 3:57 PM
  • Have you ensured you've enabled JIT Debugging in VS?  (I think it should be enabled by default...?)

    Tools | Options. In the tree, expand Debugging and click Just-In-Time.  Check the entries for the types of code for which you wish to enable JIT Debugging.
    Friday, July 1, 2005 5:46 PM
  • Yes it's all enabled. See the problem i have is when someone runs my application and it comes to a bug then they get this dialog and such recommending to turn on Jitt debugging and that's what i like i dont want them to see that screen.
    Saturday, July 2, 2005 11:43 AM
  • I really hope someone can figure it out on how to get it to work, as i still have been unable to figure it out.
    Monday, July 4, 2005 7:37 PM
  • Hi CyberOps,

    From your explanation it appears that when someone runs your application and your application encounters an unhandled exception then, they will be prompted to turn on JIT Debugging. If this is the case, you need to handle the exceptions.

    Wrap your methods correctly within try-catch blocks and handle the exceptions in a user friendly way where you show your own message.

    You can hook up to the Application.ThreadException to provide a global exception handler so that all exceptions are managed by your app.
    See this link for more details on the ThreadException:
    http://pluralsight.com/blogs/craig/archive/2004/06/13/1455.aspx

    Regards,
    Vikram
    Tuesday, July 5, 2005 1:25 AM
  • Ok but how would i do that, i looked at the link but the code provided there didnt work. Im using vb 2005 and i really like to be able to do this.
    Tuesday, July 5, 2005 10:36 AM
  • Hi CyberOps,

    The following link has a sample for VB2005.
    http://msdn2.microsoft.com/library/b602fb89(en-us,vs.80).aspx

    Regards,
    Vikram
    Tuesday, July 5, 2005 10:58 AM
  • Ok i tried the code listed below, but it doesn't work either. IS there a special place i have to add it ??? i added it at the beginning of my form

    Code below


    ' Creates a class to throw the error.
     Public Class ErrorHandler
        Inherits System.Windows.Forms.Form
     
        ' Inserts the code to create a form with a button.
     
        ' Programs the button to throw an exception when clicked.
        Private Sub button1_Click(sender As object, e As System.EventArgs)
           Throw New ArgumentException("The parameter was invalid")
        End Sub
     
        <STAThread()> _
        Shared Sub Main()
           ' Creates an instance of the methods that will handle the exception.
           Dim eh As CustomExceptionHandler = New CustomExceptionHandler()
     
           ' Adds the event handler to the event.
           AddHandler Application.ThreadException, AddressOf eh.OnThreadException
     
           ' Runs the application.
           Application.Run(new ErrorHandler())
        End Sub
     End Class
     
     ' Creates a class to handle the exception event.
     Private Class CustomExceptionHandler
     
        ' Handles the exception event.
        Public Sub OnThreadException(sender As object, t As ThreadExceptionEventArgs)
           Dim result As DialogResult = System.Windows.Forms.DialogResult.Cancel
           Try
              result = Me.ShowThreadExceptionDialog(t.Exception)
           Catch
              Try
                 MessageBox.Show("Fatal Error", "Fatal Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop)
              Finally
                 Application.Exit()
              End Try
           End Try

           ' Exits the program when the user clicks Abort.
           If (result = System.Windows.Forms.DialogResult.Abort) Then
              Application.Exit()
           End If
        End Sub
     
        ' Creates the error message and displays it.
        Private Function ShowThreadExceptionDialog(e As Exception) As DialogResult
           Dim errorMsg As StringWriter = New StringWriter()
           errorMsg.WriteLine("An error occurred please contact the adminstrator with the following information:")
           errorMsg.WriteLine("")
           errorMsg.WriteLine(e.Message)
           errorMsg.WriteLine("")
           errorMsg.WriteLine("Stack Trace:")
           errorMsg.WriteLine(e.StackTrace)
           Return MessageBox.Show(errorMsg.ToString(), "Application Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop)
        End Function
     End Class

     

    Tuesday, July 5, 2005 11:34 AM
  • Hi,

    I think things have changed with Beta2. Did some R&D and finally out how to do this in VB 2005 and Beta 2. Here are the steps:

    To manage an unhandled exception
    1. With a project selected in Solution Explorer, from the Project menu select Properties.

    2. Select the Application tab.

    3. Click the View Code button to open the Code Editor.

    4. This opens the MyEvents.vb file.

    5. With the MyEvents.vb file open in the Code Editor, from the General drop-down menu select MyApplication Events.

    6. From the Declarations drop-down menu, select UnhandledException.

    7. The application raises the UnhandledException event before the main application runs.

    8. Add code or MessageBox there which will display ur user friendly message.

    Regards,
    Vikram

     

    Tuesday, July 5, 2005 12:02 PM
  • This works, thanks for the help i greatly apreciate it.
    Tuesday, July 5, 2005 12:22 PM