简体   繁体   中英

System.UnauthorizedAccessException from Serial Port in VB.NET

I am using VB.NET 2008 Express Edition to access Serial Port which is a USB to Serial port. Since this is removable, the app user can disconnect it at any time in app. I am getting an unhandled exception when I remove the USB Serial Port.

After research, it seems like a known problem in .NET (even in 3.5)

I am looking for some solution to get this done. I have already tried the app.config solution that was suggested and it does not work

Here is the link for issue http://connect.microsoft.com/VisualStudio/feedback/Validation.aspx?FeedbackID=140018

There were a number of serial port libraries written for .Net 1.1, since it did not provide built-in classes for ports. Here is one example; there are others, open source and commercial.

You do not have to use the framework; if you use something like this, you will have access to the code right down to Win32. You might stand a better chance of catching the exception that way.

这在类似情况下帮助我,并声称可以解决.NET中SerialPort的各种问题:http: //zachsaw.blogspot.com/2010/07/net-serialport-woes.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM