Re: Hooking UnhandledException in .NET module invoked in classic ASP

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: David Browne (meat_at_hotmail.com)
Date: 03/07/05


Date: Mon, 7 Mar 2005 10:58:55 -0600


"John Snook" <JohnSnook@discussions.microsoft.com> wrote in message
news:44117C22-276F-4722-BFC4-71F739A06049@microsoft.com...
>I posted this question in microsoft.public.dotnet.framework.interop but got
> zero replies in 5 days so I'm reposting in the general framework group
> hoping
> someone's got some insight:
>
> We have a large IIS/SQL classic ASP site that we are converting to .NET by
> abstracting functionality into .NET components/methods which are also
> installed/registered as COM objects so they can by invoked by new ASPX
> pages
> as well as by our current ASP pages (Set xxx = Server.CreateObject)
>
> My question is how do I hook a handler into the UnhandledException chain
> for
> my ASP page invoked components via (Set ThisObj =
> Server.CreateObject("MyLib:MyObj")?
>
> The section of my code where I hook the chain is:
>
> If System.Web.HttpContext.Current Is Nothing Then
> 'Instantiated in the classic ASP environment
> ' ??? What goes here ???
> Else
> 'Instantiated in the ASPX environment
> Dim HttpApplication As System.Web.HttpApplication =
> System.Web.HttpContext.Current.ApplicationInstance
> AddHandler HttpApplication.Error, AddressOf
> HandleHttpExceptions
> ' This works fine to catch exceptions in the .NET assembly on
> ASPX pages
> End If
>
> I've tried the standard console application hooking:
>
> Dim CurrentDomain As AppDomain = System.AppDomain.CurrentDomain
> AddHandler CurrentDomain.UnhandledException, AddressOf
> HandleUnhandledExceptions
>
> but that doesn't seem to work across the interop/COM boundaries.
>
> Anybody got any light to shed on where the UnhandledException event chain
> lives when the .NET assembly is registered as a COM object and invoked by
> IIS's object structure?

I beleive that the managed exception is "handled" by the CCW. The exception
is caught and and a COM error is passed to COM. So the error propagates out
to the COM client and it is not unhandled. It's up to the COM client to do
something useful with the error then.

David



Relevant Pages

  • Re: covering additional use-cases in Chain of Resp.
    ... only one handling and halting the chain. ... Instead of checking if the handler can handle it, one just executes the handler and moves on through the tree. ... You just need a flexible mechanism for accessing that context information. ... Now processRequest "walks" the nextHandler references through the chain. ...
    (comp.software.patterns)
  • Re: Is notify_die being overloaded?
    ... kprobes should be using its own notify chain to trap page faults, ... I realize the page fault handler is the only performance critical event, ... but a kprobes patch removed that code. ...
    (Linux-Kernel)
  • Re: Is notify_die being overloaded?
    ... kprobes should be using its own notify chain to trap page faults, ... I realize the page fault handler is the only performance critical event, ... first ask the debuggers if the event if for them then, ...
    (Linux-Kernel)
  • Hooking UnhandledException in .NET module invoked in classic ASP
    ... We have a large IIS/SQL classic ASP site that we are converting to .NET by ... My question is how do I hook a handler into the UnhandledException chain for ... The section of my code where I hook the chain is: ... Anybody got any light to shed on where the UnhandledException event chain ...
    (microsoft.public.dotnet.framework)
  • Re: Unhandled exception was handled??
    ... exception in the Load event. ... would be reported through the UnhandledException event. ... In my example code, when there's no unhandled exception handler, nothing is ...
    (microsoft.public.dotnet.languages.vb)