netcore在Linux后台运行at Interop.ThrowExceptionForIoErrno
Posted 棉晗榜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了netcore在Linux后台运行at Interop.ThrowExceptionForIoErrno相关的知识,希望对你有一定的参考价值。
如果在控制台程序启动类末尾写了:
Console.ReadLine();
则在linux后台运行会抛出异常:
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter)
at System.ConsolePal.Read(SafeFileHandle fd, Span`1 buffer)
at System.ConsolePal.UnixConsoleStream.Read(Span`1 buffer)
at System.IO.ConsoleStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at System.IO.SyncTextReader.ReadLine()
at System.Console.ReadLine()
at Program.<Main>$(String[] args)
解决办法:
用如下代码替换Console.ReadLine();
Task.Delay(-1).Wait(-1);
Program.cs参考:
Console.WriteLine("文本内容审察...");
//启动文本检查..
TextCheckBusiness_Impl textCheckBusiness_Impl = MyInject.serviceProvider.GetService<TextCheckBusiness_Impl>();
textCheckBusiness_Impl.GetArticelListToCheck();
//无限期等待
Task.Delay(-1).Wait(-1);
转载文章:
https://blog.csdn.net/sD7O95O/article/details/119362012
以上是关于netcore在Linux后台运行at Interop.ThrowExceptionForIoErrno的主要内容,如果未能解决你的问题,请参考以下文章