The problem was a little specific but the solution may help peoples that have the same error message to understand what it is.
The procees I ran used Console.KeyAvailable
property that according to MSDN throws exception when the input to the the process is a redirected input:
InvalidOperationException : Standard input is redirected to a file instead of the keyboard.
When I changed it to Console.In.Peek, everything works fine.