Results 1 to 7 of 7

Thread: [RESOLVED] Exception Problems.

Threaded View

  1. #1

    Thread Starter
    Fanatic Member BlindSniper's Avatar
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    865

    Resolved [RESOLVED] Exception Problems.

    Hi all,
    I'm Creating a wrapper dll for my favorite Windows API functions. Normally when windows API calls fail, Nothing happens and you don't know why and this frustrates me. Although you can use their return value to determine If it was successful.

    My code (one example)
    vb.net Code:
    1. Public Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    2.         Dim result As IntPtr = Declarations.SetParent(hWndChild, hWndNewParent)
    3.         If result = IntPtr.Zero Then
    4.  
    5.             Dim ex As New System.ComponentModel.Win32Exception(Runtime.InteropServices.Marshal.GetLastWin32Error)
    6.            throw ex
    7.  
    8.  
    9.  
    10.         End If
    11.     End Function


    My problem is that when I create a new exception to be thrown I can't set the stack trace or other necessary information. I need to set this because when I just throw the exception the debugger will go to the line that threw the exception and Not the actual call.

    Any ideas ?

    EDIT: It seems like the only way is to create a custom exception. I don't want to do that since I like the Win32 exception.
    Last edited by BlindSniper; Apr 2nd, 2011 at 01:10 PM.

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