Unhandled Exception (does not look like it's happening within code

Discussion in 'ASP .Net' started by =?Utf-8?B?Q3JhaWc4MzE=?=, Sep 14, 2005.

  1. First off, I apologize if this gets long. I'm simply trying to give you all
    enough information to help me out. I'm writing (almost finished, actually),
    my first VB.Net application. It's a forms application that is going to be
    used to extract data from a legacy system (VSAM based mainframe file
    structure), and output data in pipe-delimited record layouts, multiple record
    types per file, one file per chosen client. I have been working on this
    application for about a month and it was working flawlessly until last
    Thursday. Basically, over the last week, I've been tweaking the interface
    but the base functionality had been working without issue for about a week
    and a half before I started seeing this problem.

    The application has three forms (frmMain - 2 listboxes, 1 combobox, 4
    command buttons, menu, frmDemographics - many textboxes and labels, 2 radio
    buttons, 3 command buttons, frmQuestions - textboxes, labels, two radio
    buttons, 1 multi-line textbox). The application starts with frmMain where
    the user enters an e-mail address, then chooses a data region with the
    combobox. After choosing their region, they hit the populate button which
    populates one of the listboxes. I'm retrieving the data using a data reader
    tied to an ODBC driver which allows me to access VSAM data using SQL. The
    user, after the listbox is filled with all clients from the selected region,
    selects on or more clients to export. As they double-click or highlight and
    move a client, the client is moved to a second listbox. When they are happy
    with the clients they've selected, they hit the export button.

    The click event of the export button builds a public shared string array of
    the selected clients (must have a minimum of 1 and has a maximum of 250),
    hides frmMain, then shows frmDemographics. frmDemographics displays
    demographic information for the client which the user must verify. If they
    agree with what they see, then click the "agree" radio button which enables
    the "next" button. When they click "next", the click even hides
    frmDemographic and shows frmQuestions.

    On frmQuestions, the user is required to enter a web site address, answer a
    couple questions via radio buttons, and set a couple dates (datetimepicker).
    Once they do this, they hit an "export" button, which, using client and plan
    year information, uses data readers for multiple types of client record and
    builds an output file for the client being processed. As each record is
    written to the file, a message is displayed in the multi-line text box,
    showing which record was written. After all records are written, a "finish"
    button is displayed and the user is told, in the multi-line textbox, to hit
    finish to continue.

    If all the clients are processed, the click event of the "finish" button
    will exit the application. If all clients are not processed, the array
    counter will increment so the next group is being processed, then it will
    hide frmQuestions and instantiate and show a new frmDemographics. The
    application will continue swapping between these two forms until all clients
    are processed.

    Now that you have the logic of the application, here's the problem. I've
    traced the code, line by line, and this problem occurs after the Sub has
    finished processing. Sometimes it happens after Application.Exit, sometimes
    it happens after frmDemog.Show, and sometimes it doesn't happen at all.
    Here's the code that runs right before the error:


    Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnFinish.Click
    Dim frmDemog As New frmDemographics

    frmMain.GroupCount += 1
    If frmMain.GroupList(frmMain.GroupCount) <> "" Then
    Try
    frmMain.GroupSelect = frmMain.GroupList(frmMain.GroupCount)
    frmDemographics.PLYExists = True
    DIVExists = True
    IBCExists = True
    PAYExists = True
    DISExists = True
    BNKExists = True
    ADRExists = True
    Me.Hide()
    frmDemog.Show()
    Catch eException As Exception
    MessageBox.Show("Exception has occurred: " &
    ControlChars.CrLf & "Source: " & eException.Source _
    & ControlChars.CrLf & "Description: " &
    eException.Message, "Group Extractor")
    End Try
    Else
    Try
    MsgBox("Your export files are located in " & sLocation,
    MsgBoxStyle.OKOnly, "No More Clients")
    Application.Exit()
    Catch eExcept As Exception
    MessageBox.Show("Exception has occurred: " &
    ControlChars.CrLf & "Source: " & eExcept.Source _
    & ControlChars.CrLf & "Description: " & eExcept.Message,
    "Group Extractor")
    End Try
    End If
    End Sub <--- Error always seems to happen after this line of code has
    finished processing. The application processes this line of code before the
    exeption EVERY time. Even if the application is trying to exit, and no more
    code is processed, I will get the error after this line of code. I can't
    lock down a pattern to the exception.

    The exception is:

    An unhandled exception of type 'System.NullReferenceException' occurred
    in system.windows.forms.dll

    Additional information: Object reference not set to an instance of an
    object.


    I've been working on this since Thursday morning, like I said, and have
    searched and searched all over the place. I've looked through my MSDN
    documentation, searched google until my fingers are falling off, searched the
    Microsoft Knowledge Base multiple times, and posted this same post on VBCity.
    One of the leaders on VBCity has been very helpful but he keeps telling me I
    have an error in my code, which doesn't compute with me. If the error was in
    my code, wouldn't the error have a pattern and wouldn't it happen on other
    machines?

    I've also added CustomExceptionHandler class to all the forms in an effort
    to capture the exception and have only been able to capture it twice. I
    still get the unhandled exception sometimes, with no explanation, but when I
    do get the exception handler to capture the exception, this is what I get:

    An error occurred please contact the administrator with the following
    information:

    Object reference not set to an instance of an object.

    Stack Trace:
    at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,
    IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
    at System.Windows.Forms.Control.DefWndProc(Message& m)
    at System.Windows.Forms.Control.WmDestroy(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
    IntPtr wParam, IntPtr lParam)


    Again, please accept my apology for the length of this post. Just trying to
    get you all the information. I've been pulling my hair out for six days and
    can't figure out what the heck is going on. If there was a pattern to the
    exception, I could find it and fix it. Problem is, it happens sometimes and
    doesn't happen other times. Also, when I've sent the application to other
    developers on my team (the ones that helped with the CustomExceptionHandler),
    they don't get the error. The application runs flawlessly on their machines.

    Thank you to anyone who can help me out with this.
    =?Utf-8?B?Q3JhaWc4MzE=?=, Sep 14, 2005
    #1
    1. Advertising

  2. that is a lot... and I hate to say it but sadly it's the wrong group.
    You posted this to an ASP.NET group, not a winforms group....

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "Craig831" wrote:

    > First off, I apologize if this gets long. I'm simply trying to give you all
    > enough information to help me out. I'm writing (almost finished, actually),
    > my first VB.Net application. It's a forms application that is going to be
    > used to extract data from a legacy system (VSAM based mainframe file
    > structure), and output data in pipe-delimited record layouts, multiple record
    > types per file, one file per chosen client. I have been working on this
    > application for about a month and it was working flawlessly until last
    > Thursday. Basically, over the last week, I've been tweaking the interface
    > but the base functionality had been working without issue for about a week
    > and a half before I started seeing this problem.
    >
    > The application has three forms (frmMain - 2 listboxes, 1 combobox, 4
    > command buttons, menu, frmDemographics - many textboxes and labels, 2 radio
    > buttons, 3 command buttons, frmQuestions - textboxes, labels, two radio
    > buttons, 1 multi-line textbox). The application starts with frmMain where
    > the user enters an e-mail address, then chooses a data region with the
    > combobox. After choosing their region, they hit the populate button which
    > populates one of the listboxes. I'm retrieving the data using a data reader
    > tied to an ODBC driver which allows me to access VSAM data using SQL. The
    > user, after the listbox is filled with all clients from the selected region,
    > selects on or more clients to export. As they double-click or highlight and
    > move a client, the client is moved to a second listbox. When they are happy
    > with the clients they've selected, they hit the export button.
    >
    > The click event of the export button builds a public shared string array of
    > the selected clients (must have a minimum of 1 and has a maximum of 250),
    > hides frmMain, then shows frmDemographics. frmDemographics displays
    > demographic information for the client which the user must verify. If they
    > agree with what they see, then click the "agree" radio button which enables
    > the "next" button. When they click "next", the click even hides
    > frmDemographic and shows frmQuestions.
    >
    > On frmQuestions, the user is required to enter a web site address, answer a
    > couple questions via radio buttons, and set a couple dates (datetimepicker).
    > Once they do this, they hit an "export" button, which, using client and plan
    > year information, uses data readers for multiple types of client record and
    > builds an output file for the client being processed. As each record is
    > written to the file, a message is displayed in the multi-line text box,
    > showing which record was written. After all records are written, a "finish"
    > button is displayed and the user is told, in the multi-line textbox, to hit
    > finish to continue.
    >
    > If all the clients are processed, the click event of the "finish" button
    > will exit the application. If all clients are not processed, the array
    > counter will increment so the next group is being processed, then it will
    > hide frmQuestions and instantiate and show a new frmDemographics. The
    > application will continue swapping between these two forms until all clients
    > are processed.
    >
    > Now that you have the logic of the application, here's the problem. I've
    > traced the code, line by line, and this problem occurs after the Sub has
    > finished processing. Sometimes it happens after Application.Exit, sometimes
    > it happens after frmDemog.Show, and sometimes it doesn't happen at all.
    > Here's the code that runs right before the error:
    >
    >
    > Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnFinish.Click
    > Dim frmDemog As New frmDemographics
    >
    > frmMain.GroupCount += 1
    > If frmMain.GroupList(frmMain.GroupCount) <> "" Then
    > Try
    > frmMain.GroupSelect = frmMain.GroupList(frmMain.GroupCount)
    > frmDemographics.PLYExists = True
    > DIVExists = True
    > IBCExists = True
    > PAYExists = True
    > DISExists = True
    > BNKExists = True
    > ADRExists = True
    > Me.Hide()
    > frmDemog.Show()
    > Catch eException As Exception
    > MessageBox.Show("Exception has occurred: " &
    > ControlChars.CrLf & "Source: " & eException.Source _
    > & ControlChars.CrLf & "Description: " &
    > eException.Message, "Group Extractor")
    > End Try
    > Else
    > Try
    > MsgBox("Your export files are located in " & sLocation,
    > MsgBoxStyle.OKOnly, "No More Clients")
    > Application.Exit()
    > Catch eExcept As Exception
    > MessageBox.Show("Exception has occurred: " &
    > ControlChars.CrLf & "Source: " & eExcept.Source _
    > & ControlChars.CrLf & "Description: " & eExcept.Message,
    > "Group Extractor")
    > End Try
    > End If
    > End Sub <--- Error always seems to happen after this line of code has
    > finished processing. The application processes this line of code before the
    > exeption EVERY time. Even if the application is trying to exit, and no more
    > code is processed, I will get the error after this line of code. I can't
    > lock down a pattern to the exception.
    >
    > The exception is:
    >
    > An unhandled exception of type 'System.NullReferenceException' occurred
    > in system.windows.forms.dll
    >
    > Additional information: Object reference not set to an instance of an
    > object.

    >
    > I've been working on this since Thursday morning, like I said, and have
    > searched and searched all over the place. I've looked through my MSDN
    > documentation, searched google until my fingers are falling off, searched the
    > Microsoft Knowledge Base multiple times, and posted this same post on VBCity.
    > One of the leaders on VBCity has been very helpful but he keeps telling me I
    > have an error in my code, which doesn't compute with me. If the error was in
    > my code, wouldn't the error have a pattern and wouldn't it happen on other
    > machines?
    >
    > I've also added CustomExceptionHandler class to all the forms in an effort
    > to capture the exception and have only been able to capture it twice. I
    > still get the unhandled exception sometimes, with no explanation, but when I
    > do get the exception handler to capture the exception, this is what I get:
    >
    > An error occurred please contact the administrator with the following
    > information:
    >
    > Object reference not set to an instance of an object.
    >
    > Stack Trace:
    > at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,
    > IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    > at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
    > at System.Windows.Forms.Control.DefWndProc(Message& m)
    > at System.Windows.Forms.Control.WmDestroy(Message& m)
    > at System.Windows.Forms.Control.WndProc(Message& m)
    > at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
    > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
    > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
    > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
    > IntPtr wParam, IntPtr lParam)

    >
    > Again, please accept my apology for the length of this post. Just trying to
    > get you all the information. I've been pulling my hair out for six days and
    > can't figure out what the heck is going on. If there was a pattern to the
    > exception, I could find it and fix it. Problem is, it happens sometimes and
    > doesn't happen other times. Also, when I've sent the application to other
    > developers on my team (the ones that helped with the CustomExceptionHandler),
    > they don't get the error. The application runs flawlessly on their machines.
    >
    > Thank you to anyone who can help me out with this.
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Sep 14, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?Q3JhaWc4MzE=?=

    Bruce Barker Guest

    this is the asp.net group and the question is about a winforms application.
    when you call application close, an exit message is added to the windows
    event queue, and delivered to any control interested in shutdown
    notification. you have one that references a null object.

    -- bruce (sqlwork.com)



    "Craig831" <> wrote in message
    news:...
    > First off, I apologize if this gets long. I'm simply trying to give you
    > all
    > enough information to help me out. I'm writing (almost finished,
    > actually),
    > my first VB.Net application. It's a forms application that is going to be
    > used to extract data from a legacy system (VSAM based mainframe file
    > structure), and output data in pipe-delimited record layouts, multiple
    > record
    > types per file, one file per chosen client. I have been working on this
    > application for about a month and it was working flawlessly until last
    > Thursday. Basically, over the last week, I've been tweaking the interface
    > but the base functionality had been working without issue for about a week
    > and a half before I started seeing this problem.
    >
    > The application has three forms (frmMain - 2 listboxes, 1 combobox, 4
    > command buttons, menu, frmDemographics - many textboxes and labels, 2
    > radio
    > buttons, 3 command buttons, frmQuestions - textboxes, labels, two radio
    > buttons, 1 multi-line textbox). The application starts with frmMain where
    > the user enters an e-mail address, then chooses a data region with the
    > combobox. After choosing their region, they hit the populate button which
    > populates one of the listboxes. I'm retrieving the data using a data
    > reader
    > tied to an ODBC driver which allows me to access VSAM data using SQL. The
    > user, after the listbox is filled with all clients from the selected
    > region,
    > selects on or more clients to export. As they double-click or highlight
    > and
    > move a client, the client is moved to a second listbox. When they are
    > happy
    > with the clients they've selected, they hit the export button.
    >
    > The click event of the export button builds a public shared string array
    > of
    > the selected clients (must have a minimum of 1 and has a maximum of 250),
    > hides frmMain, then shows frmDemographics. frmDemographics displays
    > demographic information for the client which the user must verify. If
    > they
    > agree with what they see, then click the "agree" radio button which
    > enables
    > the "next" button. When they click "next", the click even hides
    > frmDemographic and shows frmQuestions.
    >
    > On frmQuestions, the user is required to enter a web site address, answer
    > a
    > couple questions via radio buttons, and set a couple dates
    > (datetimepicker).
    > Once they do this, they hit an "export" button, which, using client and
    > plan
    > year information, uses data readers for multiple types of client record
    > and
    > builds an output file for the client being processed. As each record is
    > written to the file, a message is displayed in the multi-line text box,
    > showing which record was written. After all records are written, a
    > "finish"
    > button is displayed and the user is told, in the multi-line textbox, to
    > hit
    > finish to continue.
    >
    > If all the clients are processed, the click event of the "finish" button
    > will exit the application. If all clients are not processed, the array
    > counter will increment so the next group is being processed, then it will
    > hide frmQuestions and instantiate and show a new frmDemographics. The
    > application will continue swapping between these two forms until all
    > clients
    > are processed.
    >
    > Now that you have the logic of the application, here's the problem. I've
    > traced the code, line by line, and this problem occurs after the Sub has
    > finished processing. Sometimes it happens after Application.Exit,
    > sometimes
    > it happens after frmDemog.Show, and sometimes it doesn't happen at all.
    > Here's the code that runs right before the error:
    >
    >
    > Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnFinish.Click
    > Dim frmDemog As New frmDemographics
    >
    > frmMain.GroupCount += 1
    > If frmMain.GroupList(frmMain.GroupCount) <> "" Then
    > Try
    > frmMain.GroupSelect = frmMain.GroupList(frmMain.GroupCount)
    > frmDemographics.PLYExists = True
    > DIVExists = True
    > IBCExists = True
    > PAYExists = True
    > DISExists = True
    > BNKExists = True
    > ADRExists = True
    > Me.Hide()
    > frmDemog.Show()
    > Catch eException As Exception
    > MessageBox.Show("Exception has occurred: " &
    > ControlChars.CrLf & "Source: " & eException.Source _
    > & ControlChars.CrLf & "Description: " &
    > eException.Message, "Group Extractor")
    > End Try
    > Else
    > Try
    > MsgBox("Your export files are located in " & sLocation,
    > MsgBoxStyle.OKOnly, "No More Clients")
    > Application.Exit()
    > Catch eExcept As Exception
    > MessageBox.Show("Exception has occurred: " &
    > ControlChars.CrLf & "Source: " & eExcept.Source _
    > & ControlChars.CrLf & "Description: " & eExcept.Message,
    > "Group Extractor")
    > End Try
    > End If
    > End Sub <--- Error always seems to happen after this line of code
    > has
    > finished processing. The application processes this line of code before
    > the
    > exeption EVERY time. Even if the application is trying to exit, and no
    > more
    > code is processed, I will get the error after this line of code. I can't
    > lock down a pattern to the exception.
    >
    > The exception is:
    >
    > An unhandled exception of type 'System.NullReferenceException' occurred
    > in system.windows.forms.dll
    >
    > Additional information: Object reference not set to an instance of an
    > object.

    >
    > I've been working on this since Thursday morning, like I said, and have
    > searched and searched all over the place. I've looked through my MSDN
    > documentation, searched google until my fingers are falling off, searched
    > the
    > Microsoft Knowledge Base multiple times, and posted this same post on
    > VBCity.
    > One of the leaders on VBCity has been very helpful but he keeps telling me
    > I
    > have an error in my code, which doesn't compute with me. If the error was
    > in
    > my code, wouldn't the error have a pattern and wouldn't it happen on other
    > machines?
    >
    > I've also added CustomExceptionHandler class to all the forms in an effort
    > to capture the exception and have only been able to capture it twice. I
    > still get the unhandled exception sometimes, with no explanation, but when
    > I
    > do get the exception handler to capture the exception, this is what I get:
    >
    > An error occurred please contact the administrator with the following
    > information:
    >
    > Object reference not set to an instance of an object.
    >
    > Stack Trace:
    > at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc,
    > IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    > at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
    > at System.Windows.Forms.Control.DefWndProc(Message& m)
    > at System.Windows.Forms.Control.WmDestroy(Message& m)
    > at System.Windows.Forms.Control.WndProc(Message& m)
    > at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
    > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
    > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
    > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
    > IntPtr wParam, IntPtr lParam)

    >
    > Again, please accept my apology for the length of this post. Just trying
    > to
    > get you all the information. I've been pulling my hair out for six days
    > and
    > can't figure out what the heck is going on. If there was a pattern to the
    > exception, I could find it and fix it. Problem is, it happens sometimes
    > and
    > doesn't happen other times. Also, when I've sent the application to other
    > developers on my team (the ones that helped with the
    > CustomExceptionHandler),
    > they don't get the error. The application runs flawlessly on their
    > machines.
    >
    > Thank you to anyone who can help me out with this.
    Bruce Barker, Sep 14, 2005
    #3
  4. Yeah, sorry about that. I realized it after I posted the message. I've
    posted it to the dotnet.framework.windowsforms and dotnet.general. I was
    brought here from the Microsoft .Net Developer page when I clicked a link
    for hot topics.

    My apologies for the incorrect post.

    On Wed, 14 Sep 2005 09:17:08 -0700, Curt_C[ MVP] wrote:

    > that is a lot... and I hate to say it but sadly it's the wrong group.
    > You posted this to an ASP.NET group, not a winforms group....
    Craig Jeffords, Sep 14, 2005
    #4
  5. On Wed, 14 Sep 2005 09:21:22 -0700, Bruce Barker wrote:

    > this is the asp.net group and the question is about a winforms application.
    > when you call application close, an exit message is added to the windows
    > event queue, and delivered to any control interested in shutdown
    > notification. you have one that references a null object.
    >
    > -- bruce (sqlwork.com)
    >


    Yeah, sorry about that. I realized it after I posted the message. I've
    posted it to the dotnet.framework.windowsforms and dotnet.general. I was
    brought here from the Microsoft .Net Developer page when I clicked a link
    for hot topics.

    My apologies for the incorrect post.

    Thanks, though, for being the first person to explain to me what is
    happening. :)
    Craig Jeffords, Sep 14, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ola
    Replies:
    0
    Views:
    518
  2. Tedka
    Replies:
    2
    Views:
    2,651
    Mr. Dot Net
    Jul 19, 2004
  3. Blasting Cap
    Replies:
    0
    Views:
    3,566
    Blasting Cap
    May 17, 2006
  4. =?Utf-8?B?Wmlub24=?=

    Event code: 3005 - An unhandled exception has occurred

    =?Utf-8?B?Wmlub24=?=, Jun 11, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    3,936
    Walter Wang [MSFT]
    Jun 12, 2007
  5. Warren Tang
    Replies:
    1
    Views:
    859
    Warren Tang
    Sep 23, 2008
Loading...

Share This Page