After several studies, I came up with a solution:
Using the CallByName Function:
MSDN Link
This allowed me to have one function that actually performed 12 separate functions, and allowed me to have a centralized error handling system:
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
Note that you need to import Microsoft.VisualBasic.CallType into the module / class you are working on.
source
share