CrashRpt not getting installed in the override of CWinApp::Run

79 views
Skip to first unread message

eha...@hardin-soft.com

unread,
Mar 24, 2016, 11:04:43 PM3/24/16
to Crashrpt
Using VS 2010 MFC C++ on Win7 CrashRpt 1403:

I have recompiled CrashRpt per instructions and copied over the pertinent files to my app directory.
I have created an override of CWinApp::Run in  my MyApp.cpp ie
int CMDI_VSDPVApp::Run(){...}
and referenced it in MyApp.h ie
virtual int Run();

I have created this override both manually then deleted that and did the same thing trough the Class Wizard but still have the same problem.

I used the code from the CrashRpt documentation to setup the info structure and install CrashRpt within the ::Run override.

I used crEmulateCrash(CR_CPP_INVALID_PARAMETER) to emulate a crash but only got the normal crash results.  Nothing to indicate that CrashRpt intercepted the crash.

I included  crAddFile2(...) to one of my app's functions and debugged from there. Tracking the code in CrashRpt.cpp in debugger I saw that CrashRpt was not installed (pointer was null). 

I put a break point in the override of CWinApp::Run and it was never hit.

I compiled the MFCDemo solution and ran that and it runs fine.  I have compared the code in MFCDemo.h and .cpp  to MyApp.h and .cpp and cannot see any appreciable difference.  Both the MFCDemp and MyApp projects are setup with the same include and library directories.

Any ideas about why my ::Run override would not be fireing?

Thanks for any help.

Ed


eha...@hardin-soft.com

unread,
Mar 25, 2016, 4:34:02 PM3/25/16
to Crashrpt
Update from original poster:

In debugging I realized that the MyApp::InitInstance() override was never going past the two lines at the bottom
    pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
    pMainFrame->UpdateWindow();

It dawned on me that it may have something to do with Modal windows in the app.  Consequently I changed the MyApp::Run to ::RunMeFirst(), removed the lines near the bottom referring to WinApp::Run() and put the following line in the MyApp::InitInstance right above the ShowWindow() line
RunMeFirst();

That solved the problem.

Thanks.

Ed

Jeroen Walter

unread,
Apr 8, 2016, 5:48:08 AM4/8/16
to Crashrpt
If you are using the CrAutoInstallHelper class on the stack in your RunMeFirst, then you effectively just installed and directly uninstalled the crashreporter, because the destructor of CrAutoInstallHelper does that and that will be called in RunMeFirst.
Better would be to not use CrAutoInstallHelper and to just call crInstall in InitInstance and crUninstall in ExitInstance.

eha...@hardin-soft.com

unread,
Apr 8, 2016, 2:15:46 PM4/8/16
to Crashrpt
In the RunMeFirst() I have the installer as
    int nResult = crInstall(&info);   
but then I commented out the
    //crUninstall();
and put it instead at the end of my OnAppExit()

It all seems to be working fine including CrashCallback, sending email, etc.

Ed
Reply all
Reply to author
Forward
0 new messages