I am executing a Perl script on a remote server via "ExecuteCommand". The Perl script can return error and exit code <> 0. However, when ExecuteCommand sees an error or exit code <> 0, it raises SessionRemoteException and the result of the "ExecuteCommand" remains null. How can I capture the error and return code? I am using C#. NET and .NET assembly of Winscp.