views:

1385

answers:

2

I am writing a C++ COM object in Visual Studio 2008 that is an Internet Explorer Browser Helper Object. Recently, when running in IE, IE has started frequently popping up a dialog titled "Microsoft Visual C++ Runtime Library" with an error message "Runtime Error!" and going on to say that "The application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." Unlike usual, this dialog only has an OK button but no debug button, so IE then terminates and I'm not left with so much as a stack trace or even a hint of what part of my code could have been so buggy. I'm not sure where in my code it is crashing.

How does one troubleshoot a "Runtime error" problem? What are possible causes of a runtime error? (memory related bugs perhaps?) What sort of problems should I be checking my code for to attempt to eliminate this sort of crash? I need some ideas on how to troubleshoot this one, its a bit elusive.

+4  A: 

When you see that dialog, start VS2008 with your COM object project. Then use the menu Debug->Attach to process to attach the debugger to the IE process which has your COM object loaded. Then break into the process (Debug->break all) and you get the stack trace.

Stefan
+3  A: 

It bombs due to an unhandled exception. That gives you a chance to make the debugger stop on the first chance exception, right at the point where it is raised. Open your project, make iexplorer.exe the startup program. Debug + Exceptions, check the Thrown flag on the unmanaged exceptions. Make it crash to get the breakpoint.

Hans Passant