Re: How to HANDLE an Access Violation error

From: Tony Proctor (tony_proctor_at_aimtechnology_NoMoreSPAM_.com)
Date: 01/20/05


Date: Thu, 20 Jan 2005 14:40:48 -0000

No, exceptions are per-process (actually they're per-thread within each
process). I think that MSDN section (which I haven't read) simply means that
the error-mode setting (as set with SetErrorMode) is inherited by any
subprocesses you create

        Tony Proctor

"Ivan Debono" <ivanmdeb@hotmail.com> wrote in message
news:ePMja2u$EHA.3824@TK2MSFTNGP10.phx.gbl...
> The MSDN states that the error mode is for a process and its child
> processes. Does this mean that unhandled exceptions within called DLL's
and
> OCX's are handled by the parent process (EXE) too?
>
> Ivan
>
> "alpine" <alpine_don'tsendspam@mvps.org> schrieb im Newsbeitrag
> news:ftsiu09f5t1dmr8gamn98u9ui6gbdcerjf@4ax.com...
> > Here is a simple example....
> >
> > ' form code
> > Option Explicit
> >
> > Private Sub Form_Load()
> >
> > SetErrorMode SEM_NOGPFAULTERRORBOX
> >
> > SetUnhandledExceptionFilter AddressOf UnhandledExceptionFilter
> >
> > End Sub
> >
> > Private Sub Command1_Click()
> >
> > On Error GoTo EH
> >
> > ' oops :-)
> > CopyMemory ByVal 0, ByVal 10, 1000
> >
> > ExitNow:
> > Exit Sub
> >
> > EH:
> > MsgBox "The following error occured: " & CStr(Err.Number) &
> > vbNewLine & Err.Description, vbExclamation
> > Resume ExitNow
> >
> > End Sub
> > ' end form code
> >
> > ' UEF function from BAS module
> > Public Function UnhandledExceptionFilter(ExceptionInfo As
> > EXCEPTION_POINTERS) As Long
> >
> > Dim nLastDllErr&, nBuffLen&, lpBuffer&, sErrorMessage$
> >
> > nLastDllErr = Err.LastDllError
> >
> >
> > If nLastDllErr Then
> > nBuffLen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER Or
> > FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, nLastDllErr, 0&, lpBuffer, 0&,
> > ByVal 0&)
> >
> > If nBuffLen Then
> > sErrorMessage = String$(nBuffLen, vbNullChar)
> >
> > CopyMemory sErrorMessage, lpBuffer, nBuffLen
> >
> > Call LocalFree(lpBuffer)
> >
> > sErrorMessage = StrConv(sErrorMessage, vbUnicode)
> > End If
> >
> > Else
> > nLastDllErr = vbObjectError + 1
> > End If
> >
> > If Len(sErrorMessage) = 0 Then
> > sErrorMessage = "Error unknown. What ever it was that you did,
> > DON'T DO IT AGAIN!"
> > End If
> >
> >
> > UnhandledExceptionFilter = EXCEPTION_EXECUTE_HANDLER
> >
> >
> > Err.Raise nLastDllErr, "You goofus!", sErrorMessage
> >
> > End Function
> > ' end UEF function
> >
> >
> > HTH,
> > Bryan
> > ____________________________________________________________
> > New Vision Software "When the going gets weird,"
> > Bryan Stafford "the weird turn pro."
> > alpine_don'tsendspam@mvps.org Hunter S. Thompson -
> > Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
> >
> >
> > On Sat, 15 Jan 2005 14:04:55 -0500, "Al Meadows"
> > <fineware@fineware.com> wrote:
> >
> > >That is something I've had problems figuring out. If I raise an error
in
> > >the UnhandledExceptionFilter, it simply raises it again in the
> > >UnhandledExceptionFilter.
> > >
> > >Must be I'm doing something wrong.
> > >
> > >Can you show me a short UnhandledExceptionFilter function, forget all
of
> the
> > >bells and whistles than you can extract from it, but show me how to
make
> it
> > >trigger back to the original function?
> > >
> > >Example:
> > >
> > >Sub someFunction
> > >on error goto errorHit:
> > >...
> > >doSomething
> > >...
> > > exit sub
> > >errorHit:
> > > msgbox "found error"
> > >end sub
> > >
> > >Function UEF_Function(etc)
> > > ....
> > > 'comment = what do I put here
> > >
> > >end Function
> > >
> > >
> > >Al
> > >
> > >"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
> > >news:m0dgu0htfk67cluq8firqisrbd9h0q4f2o@4ax.com...
> > >> On Fri, 14 Jan 2005 11:43:02 -0800, "Al Meadows"
> > >> <AlMeadows@discussions.microsoft.com> wrote:
> > >>
> > >>>How do I Handle and trap an Access Violoation error instead of having
> it
> > >>>call
> > >>>my UnhandledExceptionFilter routine where it doesn't necessarily know
> > >>>where
> > >>>the problem arose?
> > >>>
> > >>>Basically, I just want it to fall into the specific routine's own On
> Error
> > >>>GoTo errorHit routine.
> > >>>
> > >>>Al Meadows
> > >>
> > >> Once you've handled the exception in your UnhandledExceptionFilter
are
> > >> you then raising it back to your VB error handler via the Err.Raise
> > >> method?
> > >>
> > >> HTH,
> > >> Bryan
> > >> ____________________________________________________________
> > >> New Vision Software "When the going gets weird,"
> > >> Bryan Stafford "the weird turn pro."
> > >> alpine_don'tsendspam@mvps.org Hunter S. Thompson -
> > >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
> > >
> >
>
>



Relevant Pages

  • Re: Filtering a dataset
    ... Before I knew there was a sample one on MSDN I made this one. ... It uses the dataview and is therefore probably a little bit faster, ... End Sub ... Public Function distinct(ByVal dt As DataTable, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Hintergrundbild einer 3D-Szene!
    ... Aus deiner Beschreibung geht nämlich nix hervor um einen Fehler zu ... Bei dem folgenden Code handelt es sich um eine Klasse, ... Public Sub PrepareMainMenue() ... '#Needs Exceptions ...
    (microsoft.public.de.german.entwickler.directx)
  • Re: Exception vs Boolean
    ... opinion in the context as "try to avoid" and "do as much as possible to do ... *Try* never to use an exception in a Sub because than giving back a Boolean ... exceptions and that is the crux of your misunderstanding of my position. ...
    (microsoft.public.dotnet.general)
  • Re: CORRECTION Re: confused by exception handling in VC 2008
    ... translator to convert asynchronous SEH exceptions into synchronous C++ ... So, following the MSDN ...
    (microsoft.public.vc.mfc)
  • Re: GDI+ unter Windows98
    ... MathCoprozessors, um Exceptions abzufangen, setzen sie aber nicht in den ... End Function ... Private Sub FixFPU() ... Select Case Environment.OSVersion.Platform ...
    (microsoft.public.de.german.entwickler.dotnet.framework)