Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe this should be a comment, but from the exception (and a bit of psychic debugging) it is quite "evident": </p> <p>The <code>System.Console.Clear()</code> will cause the exception you see, when the process' standard output is not attached to the console's output. Easiest reproducible when you invoke your application from the command line, and redirect its output:</p> <pre><code>MyConsoleApplication.exe &gt; NUL </code></pre> <p>Check that your SQL Agent command line doesn't contain such a redirection - actually, I'm not sure about it, but SQL Agent might automatically redirect your process' output to show it in it's log. So best thing would be to either remove the <code>System.Console.Clear()</code> call altogether , arguably it doesn't make a lot of sense in this scenario anyway. Alternatively, simply wrap it like this</p> <pre><code> try { System.Console.Clear(); } catch (IOException) { } </code></pre> <p>To ignore this particular error. Note that other Console functions/properties like <code>CursorVisible</code>, may also throw an <code>IOException</code> in that case.</p> <p>BTW, <code>CursorVisible</code> is actually a "good" candidate to write such a helper function:</p> <pre><code> bool ConsoleInputIsRedirected { get { try { bool f = System.Console.CursorVisible; return false; } catch (IOException) { return true; } } } </code></pre> <p>If you need to, you can then use this function to conditionally execute the code that does only work when the output is not redirected (like <code>Clear()</code>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload