[Last Call] Learn how to a build a cloud-first strategyRegister Now


Using SSH.NET; Method not found: 'Boolean System.Threading.WaitHandle.WaitOne(Int32)'.

Posted on 2014-08-28
Medium Priority
Last Modified: 2016-09-27
I have downloaded this tool to run some SSH commands:

on my development machine, it works just fine:
Visual Studio 2008, Project Target Framework is 3.5
the referenced DLL is the 3.5 version, though in the "runtime version" value for it, i see v2.0.50727

on the production machine, the code fails in the .dll with the message in the title.

both machines have the following .NET frameworks installed:

the relevant part of the code couldn't be simpler:
using (Renci.SshNet.SshClient c = new SshClient(_host._host, _host._username, _host._password))
                        c.ErrorOccurred += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(c_ErrorOccurred);
                        if (c.IsConnected)
                            Renci.SshNet.SshCommand cmd = c.RunCommand(_request.command);
                            request.result_data = cmd.Result;


Open in new window

what do I have to look at ?
  • 3
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 40289891
I normally put usings at the top where they belong not inline

 static void Main(string[] args)
            PasswordAuthenticationMethod authMethod = new PasswordAuthenticationMethod("debian", "temppwd");
            ConnectionInfo connectionInfo = new ConnectionInfo("", "debian", authMethod);

            using (var ssh = new SshClient(connectionInfo))
                while (true)
                    string line = Console.ReadLine();
                    if (String.IsNullOrEmpty(line))

                    var cmd = ssh.CreateCommand(line);   //  very long list
                    var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
                        // Console.WriteLine("Finished.");
                    }, null);

                    var reader = new StreamReader(cmd.OutputStream);
                    while (!asynch.IsCompleted)
                        string result = reader.ReadLine();
                        if (!String.IsNullOrEmpty(result))


Open in new window

c = new SshClient(_host._host, _host._username, _host._password))  

Where did you get this idea of how to connect?
LVL 143

Author Comment

by:Guy Hengel [angelIII / a3]
ID: 40289904

  thanks for looking at my question, though your comment/suggestions are unfortunately off-topic...

  my code works on machine 1, but not on machine 2, so I need to know what I have to look in regards to configuration...

  your code is to implement a "full" interactive ssh tool, while my app is to run just 1 command  
  Async is not needed, and I want to avoid it actually, as it might end up in a "blocking" scenario where the loop doesn't end...
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 40290271
According to the documentation, the WaitOne method overload which takes an Int32 parameter didn't show up until .NET 3.5. It sounds like you project isn't be compiled to the correct Framework version.
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 0 total points
ID: 40291972
I double-checked and ensure you that my project is compiled framework 3.5.
I went ahead and downloaded the source code, and tried to compile it in 3.5, and it failed, as some code require 4.0 framework, not sure how to proceed from there without going bad on the code and further versions.

I decided to check other SSH libraries...
LVL 143

Author Comment

by:Guy Hengel [angelIII / a3]
ID: 41817431
for anyone interested, this link I found today indicates the underlying issue:
framework 3.5 was installed, yes, but the SP1 "missing".
once I installed that one, it was working fine on the offending machine

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question