VB.NET 中串行端口的 System.UnauthorizedAccessException
我正在使用 VB.NET 2008 Express Edition 访问串行端口,这是一个 USB 转串行端口。 由于它是可移动的,应用程序用户可以随时在应用程序中断开它。 当我移除 USB 串行端口时,出现未处理的异常。
经过研究,这似乎是 .NET 中的一个已知问题(甚至在 3.5 中),
我正在寻找一些解决方案来完成此任务。 我已经尝试过建议的 app.config 解决方案,但它不起作用
这是问题的链接 http://connect.microsoft.com/VisualStudio/feedback/Validation。 aspx?FeedbackID=140018
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有许多为 .Net 1.1 编写的串行端口库,因为它没有提供端口的内置类。 这里是一个示例; 还有其他的,开源的和商业的。
您不必使用该框架; 如果您使用类似的东西,您将可以访问 Win32 的代码。 这样您可能更有机会捕获异常。
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
This helped me in a similar situation and claims to solve all kinds of problems with SerialPort in .NET: http://zachsaw.blogspot.com/2010/07/net-serialport-woes.html