I am using asynchronous methods of SSH.NET C# API to manage SFTP operations. If I specify invalid remote path in BeginDownloadFile or BeginUploadFile then the operation fails and my asyncCallback is called immediately with 0 transferred bytes count. I want to get hold of exception information but it doesn't seem to be passed. I installed an error handler on SFTP connection (ErrorOccurred) but it never gets called. Any idea of how exception can be trapped when using async methods of SSH.NET?
Asked
Active
Viewed 410 times
-1
-
do you use .net 5 ? the exception handeling has been improved / simplefied – lordkain Jan 27 '16 at 08:17
-
I am using .NET 4.5.2. – Vagif Abilov Jan 27 '16 at 08:18
-
I meant C# 6 http://www.kunal-chowdhury.com/2015/01/csharp-6-await-statement.html but for .net 4.5 there is duplicate here http://stackoverflow.com/questions/5383310/catch-an-exception-thrown-by-an-async-method – lordkain Jan 27 '16 at 08:23
-
I've found the error: I was not using EndDownloadFile in the callback handler. Once I added it there, it threw an exception. – Vagif Abilov Jan 27 '16 at 08:29
1 Answers
-1
I've found the error: I was not using EndDownloadFile in the callback handler. Once I added it there, it threw an exception.

Vagif Abilov
- 9,835
- 8
- 55
- 100