Results 1 to 6 of 6

Thread: [RESOLVED] [2008] UnauthorizedAccessException - SerialPort - USB

  1. #1

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Resolved [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]
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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!
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width