jcurl / RJCP.DLL.SerialPortStream

SerialPortStream is an independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability. Default branch is 2.x and now has support for Mono with help of a C library.
Microsoft Public License
614 stars 196 forks source link

System.StackOverflowException #101

Closed guaicaiboshi closed 4 years ago

guaicaiboshi commented 4 years ago

When my program was running for about 8 hours, I found that

System.StackOverflowException HResult=0x800703E9 Message=Exception_WasThrown

my code: try { serialPortStream?.Write(currCommand.SendBytes.ToArray(), 0, currCommand.SendBytes.Count); } catch (Exception e) { Logger.Info($"{DateTime.Now.ToLongTimeString()} info:{e}"); NextPoll(); return; } The code where the problem occurred: serialPortStream?.Write(currCommand.SendBytes.ToArray(), 0, currCommand.SendBytes.Count);

引发的异常:“System.IO.IOException”(位于 RJCP.SerialPortStream.dll 中) 引发的异常:“System.IO.IOException”(位于 RJCP.SerialPortStream.dll 中) 引发的异常:“System.TimeoutException”(位于 RJCP.SerialPortStream.dll 中) 引发的异常:“System.TimeoutException”(位于 RJCP.SerialPortStream.dll 中) 引发的异常:“AutoMapper.AutoMapperConfigurationException”(位于 AutoMapper.dll 中) 引发的异常:“AutoMapper.AutoMapperConfigurationException”(位于 AutoMapper.dll 中) 引发的异常:“System.IO.IOException”(位于 RJCP.SerialPortStream.dll 中) 引发的异常:“System.IO.IOException”(位于 RJCP.SerialPortStream.dll 中) “System.StackOverflowException”类型的未经处理的异常在 RJCP.SerialPortStream.dll 中发生

程序“[47584] dotnet.exe”已退出,返回值为 -2147023895 (0x800703e9)。

jcurl commented 4 years ago

It's difficult to know based on this description what the cause of the problem is. Using the Write method can cause the TimeoutException, but there's nothing recursive there, so please check your code.