I was looking at the ability to switch from using interop (for serial comm)
in our application to using the SerialPort class. However, the appearent
inability for the class to deal with removeable comm ports (and shutting down
the app) will definitely prevent it. Considering how many PC's no longer
have built in serial ports, the inability to deal with the port going away
really makes this class unusable for any non trivial use.
When using InterOp to access the Win32 functions WaitCommEvent() and
SetCommMask(), unplugging the USB port does not result in an exception that
causes an application shutdown.
The receivers WaitCommEvent call simply returns without showing any data has
been received.
Then calling SetCommMask to reset the event mask returns a failure, which
allows the application to know the comm port is no longer available.
MS really needs to look at fixing this. With the effort that has been put
into the creation of the SerialPort class, leaving it in this state would be
a real waste.
Ken
[quoted text, click to view] "Luke Zhang [MSFT]" wrote:
> Hello Robert,
>
> I think it is impossible to avoid of the problem, since it is a hardware
> issue, and .NET application totally reply on windows system to recognize
> and connect to the Serial port.
>
> We may find some way to catch the exceptions, and tell the user to check
> their device. For example, in Application.ThreadException event. In the
> application, we cannot expect when user will unplug it or put it back, so
> it is hard to close/ reopen the port to avoid the application. We may catch
> the exception Application.ThreadException and tell customer there may be
> an error with the USB-to-Serial converter. And, for such a hardware change,
> we had better recommend user quit current application and enter again.
>
> Sincerely,
>
> Luke Zhang
>
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. > ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>