Main.xaml (14.2 KB) Program.cs (3.9 KB)
In above workflow i’m adding a sign image to pdf it works fine, but I wants to capture the (error msg / sucess code) from exe file & save it in variable.
I attached Workflow & code file above can anybody suggest me changes in it?
If you want to capture the Error which might happen in the Invoke Code activity, then you would have to Enclose the Statements in a Try Catch Block and in the Catch you would need to assign the Exception variable outside of the activity using an out argument :
Example :
Try
Process.Start("http://www.microsoft.com")
Catch ex As Exception
out_Exception = ex
End Try
Here, out_Exception is a System.Exception type argument which has a direction Out
Dim process As New Process()
process.StartInfo.FileName = Chr(34) + ExePath + Chr(34)
process.StartInfo.Arguments = Chr(34) + InputFile + Chr(34)
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.RedirectStandardError = True
process.StartInfo.UseShellExecute = False
process.Start()
process.WaitForExit()
Dim exitCode As Integer = process.ExitCode
Dim outputMessage As String = process.StandardOutput.ReadToEnd()
Dim errorMessage As String = process.StandardError.ReadToEnd()
If exitCode = 0 Then
' Successful execution
' Store outputMessage in outputVariable
outputVariable = outputMessage
Else
' Error occurred
' Store errorMessage in errorVariable
errorVariable = errorMessage
End If