Results 1 to 10 of 10

Thread: [RESOLVED] getIcon func exceptions

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Resolved [RESOLVED] getIcon func exceptions

    hey

    I'm getting many exceptions relating to:
    Code:
        Public Function getIcon(ByVal path As String) As Icon
            Try
                Return System.Drawing.Icon.ExtractAssociatedIcon(path)
            Catch ex As System.Exception
                Return Nothing
            End Try
        End Function
    exceptions:
    Code:
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
    Please can someone help solve?

  2. #2

    Re: getIcon func exceptions

    ...well...do you see what the Exception tells you? It says FileNotFoundException which means the path you're giving the function is invalid! So why don't you work on showing what the path is when an exception is thrown instead of ignoring and returning nothing! You might as well have put
    Code:
    On Error Resume Next
    in your function as that's essentially what you're doing.

    Note that I linked you to MSDN for the exception. You should ALWAYS consult the documentation if you don't understand what's going on. I literally went to Bing (it even works the same on Google and Yahoo! as well) and typed in "System.IO.FileNotFoundException" and the MSDN library was the first result.
    Last edited by formlesstree4; May 23rd, 2013 at 03:18 PM. Reason: I checked Google & Yahoo! too.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: getIcon func exceptions

    so my func is working?

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: getIcon func exceptions

    Yes it works if the filepath points to a file that actually exists. What I don't understand is how you're getting errors with the Try/Catch in place to ignore them!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: getIcon func exceptions

    Quote Originally Posted by formlesstree4 View Post
    ...well...do you see what the Exception tells you? It says FileNotFoundException which means the path you're giving the function is invalid! So why don't you work on showing what the path is when an exception is thrown instead of ignoring and returning nothing! You might as well have put
    Code:
    On Error Resume Next
    in your function as that's essentially what you're doing.

    Note that I linked you to MSDN for the exception. You should ALWAYS consult the documentation if you don't understand what's going on. I literally went to Bing (it even works the same on Google and Yahoo! as well) and typed in "System.IO.FileNotFoundException" and the MSDN library was the first result.
    Yo don't u think i'd already researched it, that "on error resume next" is no use, with the try and catch........

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: getIcon func exceptions

    Quote Originally Posted by dunfiddlin View Post
    Yes it works if the filepath points to a file that actually exists. What I don't understand is how you're getting errors with the Try/Catch in place to ignore them!

    exceptions bud, no erros...........

  7. #7
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: getIcon func exceptions

    Tomayto, Tomahto!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  8. #8
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: getIcon func exceptions

    Quote Originally Posted by chris-2k View Post
    exceptions bud, no erros...........
    Well any exceptions caught by a try-catch are shown in the immediate window, if that is what you mean that is normal.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: getIcon func exceptions

    Quote Originally Posted by Edgemeal View Post
    Well any exceptions caught by a try-catch are shown in the immediate window, if that is what you mean that is normal.
    Yea it is, so the exceptions are only there when something is wrong...

    How can i see what value path is holding?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: getIcon func exceptions

    My brother dcrew fixed it, thanks for trying to help though.

    Code:
        Public Function getIcon(ByVal path As String) As Icon
            If (File.Exists(path)) Then Return System.Drawing.Icon.ExtractAssociatedIcon(path)
            Return Nothing
        End Function
    edit: it was also another piece of code that needed fixing, he fixed though.

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