什么是System.IO.IOException在Windows XP嵌入式版本的原因是什么? [英] What is the cause of System.IO.IOException on windows XP embedded version?

查看:405
本文介绍了什么是System.IO.IOException在Windows XP嵌入式版本的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows XP上运行一个.net 3.5应用程序embadded版本。此应用程序编写并通过串行端口(COM)读取一些数据。该应用程序工作正常,在我的笔记本电脑(Windows XP专业版),但不是在嵌入式Windows XP。我不断收到此错误:

I am running a .Net 3.5 application on Windows XP embadded version. This application writes and reads some data over the serial (COM) port. The application works fine on my laptop (windows XP Professional) but not on windows XP embedded. I keep getting this error:

System.IO.IOException:的I / O操作已中止,因为一个线程退出或应用程序请求

System.IO.IOException: The I/O operation has been aborted because of either a thread exit or an application request.

可能是什么造成的呢?

What could be the causing it?

一些额外的信息:要,我使用 ReadExisting ,而不是的Readline 阅读。另外在阅读我确保该端口是开放的了。

Some additional info: to read, I am using ReadExisting and not Readline. Also before reading I am making sure the port is open too.

System.IO.IOException: The I/O operation has been aborted because of either a thread exit or an application request.
at System.IO.Ports.SerialStream.EndRead(IAsyncResult asyncResult)
at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count, Int32 timeout)
at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.Ports.SerialPort.ReadExisting()
at ScalesApp.Scales.handleDataReceived(Object sender, SerialDataReceivedEventArgs e)
at System.IO.Ports.SerialPort.CatchReceivedEvents(Object src, SerialDataReceivedEventArgs e)
at System.IO.Ports.SerialStream.EventLoopRunner.CallReceiveEvents(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

推荐答案

的问题是,所述fAbortOnError在SetCommState的DCB,这可以解释为最抛出的SerialPort对象的IOExceptions的启用。某些电脑/手持设备都有个UART,使默认的错误标志中止 - 所以它的当务之急是一个串行口的初始化程序中清除(微软忽视了这样做)。该的SerialPort对象没有设计fAbortOnError考虑启用。

The problem is that the fAbortOnError is enabled in SetCommState's DCB, which explains for most of the IOExceptions thrown by the SerialPort object. Some PCs / handhelds have UARTs that enable the abort on error flag by default - so it's imperative that a serial port's init routine clears it (which Microsoft neglected to do). The SerialPort object wasn't designed with fAbortOnError enabled in mind.

我写了一篇长文最近来解释这个更详细(看到这个如果你有兴趣)。

I wrote a long article recently to explain this in greater detail (see this if you're interested).

这篇关于什么是System.IO.IOException在Windows XP嵌入式版本的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆