一些調查研究後,我想出了一個解決方案:
使用CallByName功能:
MSDN reference
這讓我有實際跑了12個單獨的功能之一的功能,使我能夠有一個集中的錯誤處理系統:
Private Function RunRemoteRequest(ByVal functionName As String, ByVal service_url As String, ByVal args() As Object) As Object
Dim retnVal As Object
Dim success As Boolean = False
While success = False And Me._connAttemptCount < MAX_ATTEMPTS
Try
retnVal = CallByName(remProxy, functionName, Method, args)
success = True
Me._connAttemptCount = 0
Catch ex As Exception
Me._connAttemptCount += 1
If ex.Message = "Error I am looking for" Then
Me.Login()
Else
log.Error("Error in RunRemoteRequest(" & functionName & ").", ex)
End If
End Try
End While
RunRemoteRequest = retnVal
End Function
請注意,你需要有進口Microsoft.VisualBasic程序。 CallType在您正在處理的模塊/類中。
來源
2010-05-03 18:02:52
rob
我編輯了您的答案,使其更清晰地向審閱隊列中的其他人[審閱它](http://stackoverflow.com/review/low-quality-posts/11760430),它不是僅鏈接答案。 – 2016-03-24 16:11:52
FWIW,我認爲[在你之後回答的]雙關語(http://stackoverflow.com/a/2734209/1364007)在功能上相同的內容可能不保證額外的11 upvotes它得到你的。 – 2016-03-24 16:26:29