none
Is there a way to avoid MAPI initialization crash RRS feed

  • Question

  • We have an app that performs data migration using Outlook MAPI. For a specific case where customers have installed click-to-run Outlook 2016, they decided to disable Microsoft Office click-to-run service from service windows. Our app looks through windows registry to locate the MAPI provider DLL via HKLM\Software\Clients\Mail\Microsoft Outlook\MSIComponentID. After it is successfully loaded into process, the next step is to perform MAPI initialization as the following code illustrates, it just crash out at the call to MAPIInitialize.

    MAPIINIT_0  MAPIINIT = { MAPI_INIT_VERSION, MAPI_NO_COINIT };
    m_MapiInitd = SUCCEEDED(MAPIInitialize(&MAPIINIT));

    The output debug window of vs.net shows multiple entries of the following message. Wrapping try/catch (...) or __try/__finally around MAPIInitialize call has no use as exception is not thrown to be handled:

    Exception thrown at 0x775CFD62 (KernelBase.dll) in democlient.exe: 0x000006BA: The RPC server is unavailable.

    Obviously if the Microsoft Office click-to-run service is enabled and started, this issue would NOT be there. For MSI based Outlook 2016 installation, this is NOT gonna be a problem either. 

    We would like to be able to handle this situation gracefully instead of having app exit/crash without informing the user about the problem. Current workaround we have is to check if Click-to-Run version of Outlook is installed and used on the client machine, if it is, check if the Microsoft Office click-to-run service is enabled and started and attempt to start it.  It will go on its usual business if the service is started or can be started. Only if the service fails to start, will we show an error dialog and skip calling MAPIInitialize as it would just crash the app.

    Any suggestion or alternative method to handle this gracefully?

    Thanks,

    Sean


    Saturday, December 7, 2019 5:00 PM

Answers

  • It might be a good idea to move MAPI related functionality into a separate exe and launch it from the main process if this scenario is common enough for you.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by devweb Monday, December 9, 2019 4:36 PM
    Monday, December 9, 2019 3:50 PM

All replies

  • Does Outlook itself run OK?

    Does MFCMAPI exhibit the same problem?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, December 7, 2019 5:05 PM
  • No, it does not but it handles it by showing error "Something went wrong we couldn't start your program. ... If it won't start, try repairing Office from 'Programs and Features' in the Control Panel.". We want to be able to inform user similarly instead of crashing out.

    Interestingly when the Microsoft Office click-to-run service is disabled, running MFCMAPI tool (v 15.0.0.1043) also crashes out.
    Saturday, December 7, 2019 6:06 PM
  • You might want to test with the latest release of MFCMAPI (19.2.19207.938).  You can get it at https://github.com/stephenegriffin/mfcmapi/releases/tag/19.2.19207.938

    If the latest release does not have a problem when the the Microsoft Office click to run service is disabled you may be able to see how MFCMAPI handles it.

    Saturday, December 7, 2019 6:35 PM
  • Unfortunately it is the same result, the MFCMAPI (19.2.19207.938) crashes out without any indication. I was hoping for the same thing to see if it handles the problem better.
    Saturday, December 7, 2019 6:52 PM
  • There is no crash here (6ba is a common benign exception). The c2rdll module calls TerminateProcess when it cannot connect to the service because failure to connect to that service is a fatal exception. We *do* show a dialog for applications which are part of the C2R package, but all others will just silent exit, by design.

    My recommendation is that you ensure the service is enabled.


    Monday, December 9, 2019 3:35 PM
  • It might be a good idea to move MAPI related functionality into a separate exe and launch it from the main process if this scenario is common enough for you.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by devweb Monday, December 9, 2019 4:36 PM
    Monday, December 9, 2019 3:50 PM
  • Thanks for the suggestion. Definitely another workaround to the problem.
    Monday, December 9, 2019 4:36 PM
  • Good to know. I am curious how Outlook is able to test it without the process being terminated. 
    Monday, December 9, 2019 4:40 PM
  • Outlook is killed in exactly same way, but for Outlook you get the prompt before TerminateProcess is called.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, December 9, 2019 4:43 PM