title: ReadKey InvalidOperationException application does not have a console
body: <p>I am trying to use <code>ReadKey()</code> to get a password field so it doesn't show in the console for a .net core app I am running on Ubuntu.</p>
  <p>This is code:</p>
  <pre class="lang-cs prettyprint-override"><code>while (true)
  {
      var key = System.Console.ReadKey(true);
  
      if (key.Key == ConsoleKey.Enter)
          break;
  
      Io.RootPass += key.KeyChar;
  } 
  </code></pre>
  <p>But I get this exception:</p>
  <blockquote>
  <p>Exception has occurred: CLR/System.InvalidOperationException
  An unhandled exception of type 'System.InvalidOperationException' occurred in System.Console.dll: 'Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.'</p>
  </blockquote>
  <p><code>Console.ReadLine()</code> doesn't work either it just doesn't throw an exception. The return value is not assigned when enter hit so the program sticks.</p>
  <p>I am guessing this is because Linux terminal works differently. Is there a different interface for Linux terminal that works?</p>
  <p>Thanks!</p>