I have a "App Window" that I have been using for some months now. Every once in awhile I get a unhandled exception with the below text
Code:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at AppWindow.Form1.Timer2_Tick(Object sender, EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is there something that anybody sees that I shouldn't be doing or a problem in the code? My problem is I don't know where the error is exactly.

Here is the function

Code:
Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim curNode As TreeNode = Me.tvFolders.SelectedNode
        If curNode.ToString.Length = 0 Then
            curNode = tvFolders.Nodes("Jackson County")
        End If
        Dim SelectNode As String = curNode.Name
        Try

            ' check to see if file exist, if so do refresh then delete file
            If (File.Exists(appPath & "refresh.ini")) Then
                File.Delete(appPath & "refresh.ini")
                Me.Update()
                ' this clears icons, 
                lvFiles.Items.Clear()
                FillTreeView()
                InitializeTimer()

                'MsgBox("1 " & SelectNode)
                If curNode.Text = "Personal" And My.Settings.Favorites.Count = 0 Then
                    tvFolders.Nodes.Remove(tvFolders.Nodes("Personal"))
                    curNode = Nothing
                End If
                'Me.tvFolders.SelectedNode = curNode
                If curNode.ToString.Length > 0 Then
                    If curNode.Text = "Personal" And My.Settings.Favorites.Count > 0 Then
                        SelectNode = appPath & favorites(0)
                    End If
                    Dim theNode() As TreeNode = tvFolders.Nodes.Find(SelectNode, True)
                    'MsgBox("node length:" & theNode.Length)
                    If theNode.Length > 0 Then
                        'MsgBox("2 " & theNode(0).Text)
                        Me.tvFolders.SelectedNode = theNode(0)
                    End If

                Else
                    'MsgBox("curnode is blank")
                    Me.tvFolders.SelectedNode = tvFolders.Nodes("Jackson County")
                End If
                'MsgBox(Me.tvFolders.SelectedNode)
                objFS.ListFoldersFiles(Me.tvFolders.SelectedNode.Tag, lvFiles, ImageList2)
                'MsgBox(curNode.Text)
                Timer2.Enabled = False
                Cursor.Current = System.Windows.Forms.Cursors.Default

                ToolStripStatusLabel1.Text = ""
                Me.tvFolders.Focus()
                tvFolders.LabelEdit = False
            Else
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
                InitializeTimerRefresh()
            End If
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
            MsgBox("Refresh Failed" & Chr(13) & Chr(13) & ex.Message, vbOKOnly, "Failed To Refresh Timer")
        End Try
    End Sub