1

I made an application that our company uses to launch databases and updates them on the users machine, when needed.

I am having a slight problem when it comes to launching databases and the database starts up slow. When this occurs my application throws an exception, as I assuming its awaiting some kind of response back.

As of now the error thrown is: The system cannot find the file specified

I am trying to prevent this exception logging for cases like this(Slow Application), but still allow the logging if a real error occurs while opening a database.

Current Code I am using:

Private Sub OpenApplication()

    If File.Exists(LocalPathString) Then                    ' File Found. Open the File.
        Try

            Dim ps As New Process
            ps = Process.Start(LocalPathString)

        Catch ex As Exception
            ex.Source += " | " & LocalPathString
            RaiseEvent ShowError(ex)
        Finally
            RaiseEvent CancelIt()                               ' Thread Complete. Close the ActionForm
        End Try
    Else
        If LocalPathString = vbNullString Then
            RaiseEvent CancelIt() ' No file exits. Cancel thread.
        Else
            RaiseEvent ShowError(New Exception("Database Not Located: " & LocalPathString))
        End If
    End If
End Sub

StackTrace:

 System.Diagnostics.Process.StartWithShellExecuteEx(startInfo As ProcessStartInfo)
       App.exe: N 00912

   System.Diagnostics.Process.Start()
       App.exe: N 00136

   System.Diagnostics.Process.Start(startInfo As ProcessStartInfo)
       App.exe: N 00049

   SAMi.ActionClass.OpenApplication()
       App.exe: N 00117
4

1 回答 1

0

也许我遗漏了一些东西,但是如果您发现了特定的异常,为什么不简单地省略日志记录呢?

   Catch ex As Exception
        ex.Source += " | " & LocalPathString
        if not ex.Message.Contains("The system cannot find the file specified") Then
            RaiseEvent ShowError(ex)
        end if
于 2013-06-05T12:55:22.010 回答