안녕하세요, 저는 현재 개발중인 응용 프로그램에서 일부 통합 테스트를 수행하고 있습니다. 문제의 원인이되는 특정 요소는 Oracle 데이터베이스를 질의하는 백그라운드 작업자 호출입니다. 쿼리에서 오류가 발생하면 응용 프로그램 수준의 호출 스택을 예외 세부 사항에 표시하고 그 시점에서 적절한 사용자 호환 메시지를 제공해야합니다. 상기 BackgroundWorker에의 DoWork 하위에백그라운드 작업자의 처리되지 않은 예외
System.Reflection.TargetInvocationException was unhandled
Message: An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an
invocation.
:
Oracle.DataAccess.Client.OracleException ORA-00907: missing right parenthesis
불행히도 코드는 다음과 같은 예외가 발생하는 경우를 예시적인 테스트에서 신택스 에러가 OraEx 예외 결과를 기초 SQL에 존재 내 믿음에도 불구하고 나는 예외를 정확하게 처리하고있다. 그것의 꽤 명백한 내가 여기에 뭔가 근본을 놓치고있다, 누군가가 해결책을 제발 제안 할 수 있습니다.
Private Sub uxBWScan_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles uxBWScan.DoWork
Const procName As String = "uxBWScan_DoWork"
Try
e.Argument.CountRecords(_queryTypeID)
e.Result = e.Argument.RecordCount
Catch NullEx As NullReferenceException
_logger.SendLog(NullEx.Message & ". Thrown in module " & Me.Name.ToString & "." & procName, NLog.LogLevel.Error, NullEx)
Throw
Catch OraEx As OracleException
_logger.SendLog(OraEx.Message & ". Thrown in module " & Me.Name.ToString & "." & procName, NLog.LogLevel.Error, OraEx)
Throw
Finally
End Try
End Sub
: 여기
Private Sub EventSearch(ByVal mySQL As String)
Const procName As String = "EventSearch"
Try
_eventMngr = New ScadaEventManager(_CurrentDB, _userName, _myPwd)
_eventMngr.SQL = mySQL
'Set the flag and stop query tool status accordingly
_Stopped = False
uxStopQueryTool.Enabled = True
'activate the timer object to ensure that the execute query menu
'and tool remain disabled until all background processing is complete
uxBackWorkTimer.Enabled = True
_logger.SendLog(Me.Name & "." & procName & " - Scanning for data.", NLog.LogLevel.Trace)
ReviseStatus(2, "Scanning for data. Please wait...", Color.Black, True, True)
'Force the thread to sleep for half a second so the user can see the scanning state taking place
Threading.Thread.Sleep(500)
'Launch the background worker to retrieve the required data from the database
uxBWScan.RunWorkerAsync(_eventMngr)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, My.Application.Info.ProductName)
_logger.SendLog(ex.Message & ". Thrown in module " & Me.Name.ToString & "." & procName, NLog.LogLevel.Error, ex)
Call ResetStatus()
Finally
End Try
End Sub
그리고 백그라운드 작업자에 의해 실행되는 코드입니다 : 사전에
감사 폴 J. 여기
는 백그라운드 작업자에 대한 호출을 만드는 코드는
오류를 생성하는 하위 수준 코드는 다음과 같습니다.
Public Sub CountRecords(ByVal queryType As Integer)
_myDataset = New DataSet
Try
_myDataset = _myScadaEventDB.CountRecords(_sqlText)
If _myDataset.Tables(0).Rows.Count > 0 Then
If queryType = Enums.QueryType.General Or queryType = Enums.QueryType.KeyPerformanceIndicators Or queryType = Enums.QueryType.TelecontroAnalysis Then
_recordCount = _myDataset.Tables(0).Rows(0).Item("RecordCount")
Else
'The query is grouped therefore count the number of records in the table
_recordCount = _myDataset.Tables(0).Rows.Count
End If
Else
_recordCount = 0
End If
Catch ex As Exception
Throw
Finally
End Try
End Sub
자세한 내용을 보려면 내면 예외를 확인하십시오 (그리고 예상되는 예외 일 수도 있음). – N0Alias
이벤트 인수에서'CountRecords'를 호출하면 초기 바인딩 또는 런타임에 바인딩됩니까? 'e.Argument'의 유형은 무엇입니까? 나는 이것이 늦은 바운드 호출일지도 모른다고 생각한다. 그러므로 예외는'TargetInvocationException'에 싸여있다. 위의 주석에 따라,'TargetInvocationException'의'InnerException'을 보아 그것이 당신이 기대 한 것이 었는지 알 수 있습니다. – Craig
@Craig : 늦은 전화입니다. [** DoWorkEventArgs.Argument' 속성 **] (https://msdn.microsoft.com/en-us/library/system.componentmodel.doworkeventargs.argument (v = vs.110) .aspx)은' 개체'. –