title: C# Renci.SshNet.Sftp Connect throwing ArgumentNullException
body: <p>I am using Renci.SshNet.Sftp to connect to SFTP. I am getting the following error when I try to call <code>sftpClientObject.Connect()</code>. Please find below the error. It was working fine couple of days ago. Checked the authentication details and it is perfect.</p>
  
  <pre><code>var _sftpClient = new SftpClient(_hostName, _userName, _password);
  using (_sftpClient)
  {
      _sftpClient.Connect();
      // Other code to follow
  }
  </code></pre>
  
  <blockquote>
    <p>Error:<br>
    Value cannot be null.<br>
    Parameter name: At least one element in the specified array was null.</p>
  </blockquote>
  
  <p>Exception stacktrace:</p>
  
  <pre class="lang-none prettyprint-override"><code>   at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext)
     at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, TimeSpan timeout, Boolean exitContext)
     at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, TimeSpan timeout)
     at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle)
     at Renci.SshNet.PasswordAuthenticationMethod.Authenticate(Session session)
     at Renci.SshNet.ConnectionInfo.Authenticate(Session session)
     at Renci.SshNet.Session.Connect()
     at Renci.SshNet.BaseClient.Connect()
     at SftpPoller.FileTransferClient.ProcessFilesInSftp(TextWriter log) in 
  </code></pre>
  
  <p>But when I use the following code, it worked:</p>
  
  <pre><code>var methods = new AuthenticationMethod[1];
  methods[0] = new PasswordAuthenticationMethod(_userName, _password);
  var con = new ConnectionInfo(_hostName, _userName, methods) {Timeout = new TimeSpan(0, 0, 0, 60)};
  _sftpClient = new SftpClient(con);
  </code></pre>
  
  <p>Can anyone help me how to solve this issue?</p>
  
  <p>Thanks</p>