JohnTheGr8 / Renci.SshNet.Async

Extends Renci.SshNet to implement the task-based async pattern
MIT License
67 stars 24 forks source link

Update for compatibility with SSH.NET > 2020.0.2 #20

Open pjninnis opened 1 month ago

pjninnis commented 1 month ago

This Async library isn't compatible with later versions of SSH.NET (eg latest 2024.1.0), assumably due to missing/renamed methods. eg System.MissingMethodException: Method not found: 'System.Collections.Generic.IEnumerable1 Renci.SshNet.SftpClient.EndListDirectory(System.IAsyncResult)'. at Renci.SshNet.Async.SshNetExtensions.ListDirectoryAsync(SftpClient client, String path, Action1 listCallback, TaskFactory`1 factory, TaskCreationOptions creationOptions, TaskScheduler scheduler)

mikeries commented 1 month ago

@pjninnis I just discovered this issue also, and after some poking around I found that support for a lot of async stuff was added to the core SSH.Net library. I was able to get around this by getting rid of Renci.Ssh.Net.Async and using the native support in SSH.Net.

eg. var files = await sftpClient.ListDirectoryAsync("files", cancellationToken: token);

Hope that helps you!

pjninnis commented 1 month ago

Thanks, but I'm a bit confused.

I'm not seeing any of the Async methods in the SftpClient class in the latest SSH.Net Nuget from Renci https://www.nuget.org/packages/SSH.NET (2024.0.1) BUT I do see them in the source code on https://github.com/sshnet/SSH.NET

I'm using .NET 8

mikeries commented 1 month ago

Hmm... not sure if I can provide too much guidance on that. I'm also using dotnet 8 and SSH.NET 2024.1.0.

You need

using Renci.SshNet.Sftp;
using Renci.SshNet;