Re: how can I create minidumps of second chance exceptions in .NET 1.1 managed code?



Thanks, Oleg,
I tried your suggestion, but it has a problem:
Using the configuration like you suggested sends the exception to the JIT debugger which is registered in a system-wide manner, and I don't want to register there.
When my app crashes, I want to catch that crash, create a dump and show a friendly message to the user. If I did that through the JIT debugger, I would be showing my message even when other applications crash.
That's why I'm running my app by using ADPlus.
Just to be sure, you wrote:
"From my experience, ADPlus (as well as other unmanaged debuggers) is usually good in catching 2nd chance managed exceptions."
Did you really mean *managed* in that sentence, or *unmanaged* ?


BTW, I understand that your suggestion comes from the "details" in the unhandled exception window, but I couldn't find any MSDN documentation of that "system.windows.forms" tag - is there any such documentation? maybe it has more attributes that could help.

Thanks
Uri

Oleg Starodumov wrote:
I've written a test Windows Forms (.NET 1.1) app, with the following event:
         private void Form1_Load(object sender, System.EventArgs e)
         {
             int i = 0;
             int j = 9 / i; /* I WANNA DUMP HERE :-) */
         }
And I want to produce a minidump of the second-chance exception that
occurs (I don't want the 1st chance - every 3rd party control I use
produces at least 2 of those whenever the app is run).

If I could do this, I'd have my users run my app this way every time
(I'll hide the debugger windows, etc. and I believe performance won't be
degraded by this as long as a 2nd chance exception isn't met) and when
they get a crash, I could get a dump file.
That said, my preference would be for solutions that don't require
changing registry keys, but for now any solution goes for the sake of
discussion and learning.

I guess it should be somehow possible to do this, because the VS.NET
2003 IDE debugger stops on the remarked line.

I tried using ADPlus, but it appears that it can't catch 2nd chance
managed exceptions, because the .NET CLR catches them (And writing a
AppDomain.UnhandledException handler swallows them).



From my experience, ADPlus (as well as other unmanaged debuggers) is usually good
in catching 2nd chance managed exceptions. The problem is with WinForms applications,
which catch/swallow unhandled exceptions thrown from event handlers.
This behavior can be changed in the application's .config file. Something like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

With this enabled, you can even employ the unmanaged JIT debugger (e.g. Dr.Watson)
to produce the crash dump if you call SetUnhandledExceptionFilter via interop
and set the filter pointer to zero (though it in turn will not allow managed debuggers
to receive second chance managed exceptions in normal debugging sessions).

Oleg






.



Relevant Pages

  • Re: how can I create minidumps of second chance exceptions in .NET 1.1 managed code?
    ... If I did that through the JIT debugger, ... because managed exceptions are implemented with the help ... Use ADPlus _and_ enable WinForms JIT debugging in the .config file. ...
    (microsoft.public.vsnet.debugging)
  • RE: Disabling exception trace messages
    ... a tick comparison shows the following: ... Outside debugger: ... > Can you tell me why this now takes so much longer than VC6? ... >> break on a given type of exception or on a category of exceptions. ...
    (microsoft.public.vc.debugger)
  • Re: Step by Step skips large chunks of code
    ... Do your threads throw exceptions, ... the debugger will automatically break it when an exception is thrown. ... You can send feedback directly to my manager at: ... Added SP1, the debugger started skipping within threads. ...
    (microsoft.public.vsnet.debugging)
  • Re: Mixed assembly crashes on exit
    ... (when running the app under debugger, watch also for unexpected first chance ... exceptions in Debug Output window, or configure the debugger to stop ... Also try to set breakpoint in SingletoneDomainUnload function and step ... how does the disassembly around the place of crash look? ...
    (microsoft.public.vsnet.debugging)
  • Re: Set DEBUG flag at runtime?
    ... always break on exceptions, even if there was a catch block. ... debugger to break in the place where the exceptions occur when debugging, ... DEBUG mode rather than RELEASE. ...
    (microsoft.public.dotnet.languages.csharp)