0 votes
by (120 points)

Target Framework: netstandard2.0
Rebex.Sftp (3.0.6690)

System.MissingMethodException : Method not found: 'Void Rebex.Net.Sftp.add_FingerprintCheck(System.EventHandler`1<Rebex.Net.SshFingerprintEventArgs>)'.

Error occurs when you try to add a handler for the Sftp.FingerprintCheck event.

Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)

I assume that you have a .NET Standard 2.0 library that references Rebex SFTP, and you are using that .NET Standard 2.0 library from a .NET 4.6.x application (or library).

If that's the case, then this is caused by the unfortunate fact that .NET 4.6 console app actually gets .NET 4.0 binaries of Rebex.Sftp, while the .NET Standard 2.0 library is linked against .NET Standard 1.5 binaries of Rebex.Sftp, and those two versions are not compatible (there is a a slight difference in FingerprintCheck event, among others).

In an ideal world, this would be simple to solve by making the .NET 4.6 app reference .NET Standard 1.5 binaries of Rebex.Sftp as well. But unfortunately, as of today, Visual Studio does not seem to support this (although third-party NuGet package managers such as Paket might).

In future, this issue will disappear because we plan to release a .NET Standard 2.0 binaries and .NET 4.6 binaries with identical APIs soon.

Until then, there are two temporary workarounds:

a) Use multi-targeting in the .NET Standard library. Remove line from its project file and add something like netstandard2.0;net461 instead. See https://www.rebex.net/getfile/f4a9b734408e4e8d8c63a8046784a0a1/RebexSftpSample-CoreApp1b.zip for an example.

b) Create customized versions of Rebex NuGet packages that only contain the .NET Standard binaries of Rebex SFTP (and not .NET 4.x binaries). This would prevent Visual Studio from picking a wrong set of binaries for .NET 4.6. Unfortunately, this requires using a custom NuGet repository instead of NuGet.org. If you would like us to create these packages for you, let me know.

by (120 points)
This makes sense.  Until the 2.0 standard  libraries are released I will target net461 in my class library rather than netstandard2.0 which seemed to resolve the issue.  Thanks for the quick update.
...