[VB.net] - Dealing with First Chance Exceptions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zubair1
    New Member
    • Sep 2008
    • 79

    [VB.net] - Dealing with First Chance Exceptions

    Hi,

    Today, i added some new code which was to see if a file is locked or not (in use by another application). While i did that it was showing me some errors like in the Output window:-

    Code:
    A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.IO.IOException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.IO.IOException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.IO.IOException' occurred in Microsoft.VisualBasic.dll
    A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.VisualBasic.dll
    Can some help and tell me if this is any serious problem, after searching for a while and reading very confusing articals i couldn't understand if it is or not - if i understand correctly what they meant they said it wasn't important and i should ignore these messages?

    Thanks in advance
    Regards
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Check out this article about first chance exceptions, it may be useful:

    The home for technical questions and answers at Microsoft. Get started asking, answering, and browsing questions about products like .Net, Azure, or Teams.

    Comment

    • zubair1
      New Member
      • Sep 2008
      • 79

      #3
      Originally posted by balabaster
      Check out this article about first chance exceptions, it may be useful:

      http://social.msdn.microsoft.com/For...-f3c840d72b55/
      Thanks, it was pretty useful.

      I think i understand it alittle but just not sure if i should ignore these..

      The post you pointed to sort of makes the same suggestion but says it really depeneds on the application :s i got those exceptions when i was trying to see if a file is opened by trying to write in it or delete it.

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        Originally posted by zubair1
        Thanks, it was pretty useful.

        I think i understand it alittle but just not sure if i should ignore these..

        The post you pointed to sort of makes the same suggestion but says it really depeneds on the application :s i got those exceptions when i was trying to see if a file is opened by trying to write in it or delete it.
        In my experience they can mostly be ignored, but personally I can't stand leaving unhandled exceptions in my code, even if they are outwardly harmless.

        Comment

        • zubair1
          New Member
          • Sep 2008
          • 79

          #5
          Thanks :)

          Do you think i should i worry about these messages that i am getting then?

          They are not unhandled right?


          Regards

          Comment

          • balabaster
            Recognized Expert Contributor
            • Mar 2007
            • 798

            #6
            Originally posted by zubair1
            Thanks :)

            Do you think i should i worry about these messages that i am getting then?

            They are not unhandled right?


            Regards
            Well theoretically, they occur because you have a method that throws an exception that may or may not be handled. It is a second chance exception that causes your application to crash. So you will always encounter first chance exceptions - if you are handling them, you can ignore them.

            Comment

            • zubair1
              New Member
              • Sep 2008
              • 79

              #7
              Originally posted by balabaster
              Well theoretically, they occur because you have a method that throws an exception that may or may not be handled. It is a second chance exception that causes your application to crash. So you will always encounter first chance exceptions - if you are handling them, you can ignore them.

              ahhh oh ok great, thanks alot :)

              Comment

              Working...