Unhandle exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roy

    #1

    Unhandle exception

    Hi all,
    I'm getting an error messagebox that displays for less than a second and
    disappers. I found the line that causing this error, and enclosed in a try
    block, but I'm not able to catch this error and hide it from user to see it.
    (I wasn't either able to see the error through Console.WriteLi ne). This
    message has three buttons: Details, Quit, and Continue. I cannot read the
    message and not able to catch it. Is there a way to catch this error?So, the
    user wouldn't see the error. The application runs after this message with no
    problem, and doesn't crash.
    Code:
    MyDataGrid.Data Source = ds.Tables("Tabl e1")
    'ds(dataset )is populated and always has rows. MyDataGrid is a customized
    data grid control. I don't have any problem when assigning DataSource
    property of the data grid for the first time, but after adding, deleting
    records and trying to refresh the data grid control this line causes the
    error message to be displayed.
    Thanks for your input.
    Roy

  • Armin Zingler

    #2
    Re: Unhandle exception

    "Roy" <Roy@discussion s.microsoft.com > schrieb[color=blue]
    > Hi all,
    > I'm getting an error messagebox that displays for less than a second
    > and disappers. I found the line that causing this error, and
    > enclosed in a try block, but I'm not able to catch this error and
    > hide it from user to see it. (I wasn't either able to see the error
    > through Console.WriteLi ne). This message has three buttons: Details,
    > Quit, and Continue. I cannot read the message and not able to catch
    > it. Is there a way to catch this error?So, the user wouldn't see the
    > error. The application runs after this message with no problem, and
    > doesn't crash. Code:
    > MyDataGrid.Data Source = ds.Tables("Tabl e1")
    > 'ds(dataset )is populated and always has rows. MyDataGrid is a
    > customized data grid control. I don't have any problem when
    > assigning DataSource property of the data grid for the first time,
    > but after adding, deleting records and trying to refresh the data
    > grid control this line causes the error message to be displayed.
    > Thanks for your input.
    > Roy[/color]

    Have you tried putting the whole thread's main procedure into a try-catch
    block?

    If you're startup object (in project properties) is sub main, put the code
    in sub main in a try-catch block.

    If the startup object is a Form, add the following code to the Form:

    shared sub main
    try
    AddHandler Application.Thr eadException, AddressOf OnThreadExcepti on
    application.run (new form1)
    catch ex as exception
    stop
    end try
    end sub

    Private Shared Sub OnThreadExcepti on( _
    ByVal sender As Object, _
    ByVal e As System.Threadin g.ThreadExcepti onEventArgs)

    stop

    End Sub

    Replace form1 by the class name of your startup form.

    This is only an attempt. I'm also fighting with the problem of unhandable
    exceptions (in timer.tick event handlers).

    Can the exception be caught by one of the two handlers?

    Armin

    Comment

    • Cor Ligthert

      #3
      Re: Unhandle exception

      Roy,

      I have as well seen that Microsoft has used the try and catch block to
      *handle* datagrids.

      It gives in my opinion anoying behaviour, especially because you don't know
      where it is done.

      It is done as well by the IsDate and the IsNumeric, however there you see no
      side effects.

      Cor


      Comment

      • Roy

        #4
        Re: Unhandle exception

        Cor,

        Since this error doesn't cause any issues, is there a way to catch the error
        and hide it from the user.
        Thanks again,

        Roy

        "Cor Ligthert" wrote:
        [color=blue]
        > Roy,
        >
        > I have as well seen that Microsoft has used the try and catch block to
        > *handle* datagrids.
        >
        > It gives in my opinion anoying behaviour, especially because you don't know
        > where it is done.
        >
        > It is done as well by the IsDate and the IsNumeric, however there you see no
        > side effects.
        >
        > Cor
        >
        >
        >[/color]

        Comment

        • Cor Ligthert

          #5
          Re: Unhandle exception

          Roy,

          Have you set in your IDE while your program is loaded in DEBUG the Exception
          behaviour while debugging. Debug->Exceptions

          Than you can set on what Exceptions your program has to stop while
          debugging. Maybe can you find it and place yourself something around it.

          For the rest I would not know how I could help you in this.

          Cor


          Comment

          • Roy

            #6
            Re: Unhandle exception

            Cor thanks again,
            I know exactly what line is causing the problem, but I'm out of luck to
            catch it with try block.

            "Cor Ligthert" wrote:
            [color=blue]
            > Roy,
            >
            > Have you set in your IDE while your program is loaded in DEBUG the Exception
            > behaviour while debugging. Debug->Exceptions
            >
            > Than you can set on what Exceptions your program has to stop while
            > debugging. Maybe can you find it and place yourself something around it.
            >
            > For the rest I would not know how I could help you in this.
            >
            > Cor
            >
            >
            >[/color]

            Comment

            Working...