[C#]“System.InvalidOperationException”类型的未经处理的异常在 System.Console.dll 中发生

当使用VSCode调试C#应用并遇到'Cannot read keys when either application does not have a console or when console input has been redirected.'错误时,可以在launch.json文件中设置'console'为'integratedTerminal'或'externalTerminal',使应用在VS Code的集成终端或外部终端运行,从而解决Console.ReadLine()无法正常工作的问题。
摘要由CSDN通过智能技术生成

错误提示:

“System.InvalidOperationException”类型的未经处理的异常在 System.Console.dll 中发生 : ‘Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.’

在这里插入图片描述


在OmniSharp Visual Code docs里找到了答案:

Console (terminal) window

By default, processes are launched with their console output (stdout/stderr) going to the VS Code Debugger Console. This is useful for executables that take their input from the network, files, etc. But this does NOT work for applications that want to read from the console (ex: Console.ReadLine). For these applications, use a setting such as the following:
“console”: “integratedTerminal” When this is set to integratedTerminal the target process will run inside VS Code’s integrated terminal. Click the ‘Ter

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值