[RESOLVED] [2008] UnauthorizedAccessException - SerialPort - USB
UnauthorizedAccessException happens when a USB connected SerialPort is disconnected(physically) and the form is closed.
There does not appear to be a way to Catch the exception and it is not handled with
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
How can this exception be captured. BTW - the Call Stack shows [ExternalCode]
Re: [2008] UnauthorizedAccessException - SerialPort - USB
Quote:
Originally Posted by dbasnett
How can this exception be captured. BTW - the Call Stack shows [ExternalCode]
This would lead me to believe that the exception is thrown within the Win32 API but I don't know for sure.
Will a regular System.Exception catch not catch the Exception? If that nor the Unhandled Exception event cannot catch the exception then... well, I don't know.
Re: [2008] UnauthorizedAccessException - SerialPort - USB
there is not "a" line that is pointed to when the error occurs.
a lot of people have the problem, and it is posted and being ignored for the most part on MSDN.
of course the answer is for the user not to pull the adapter before closing the application, but until PC's have a built-in TASER users do what users want ;)
Re: [2008] UnauthorizedAccessException - SerialPort - USB
Quote:
Originally Posted by dbasnett
there is not "a" line that is pointed to when the error occurs.
Put the entry point of the application in a Try and see if it catches it. Other than that I have no idea. Good luck!
Re: [2008] UnauthorizedAccessException - SerialPort - USB
There is a bug for this (resolved of course).
https://connect.microsoft.com/Visual...dbackID=140018
It says add this as a work around to the app.config.
<configuration>
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
</configuration>
I have no idea where that(app.config) is.
Re: [2008] UnauthorizedAccessException - SerialPort - USB
That's your application config. All web applications have a web.config and all windows forms applications have an app.config file.