none
Ribbon/RibbonWindow of Microsoft Ribbon for WPF causes Word Crash

    Question

  • I developed a simple Word 2007 addin using VS 2010 VSTO, in the addin I simply want to display WPF RibbonWindow like this:

       if (System.Windows.Application.Current == null)
       {
        //I get same result when deleteing the following two lines
        WpfApp = new System.Windows.Application();
        WpfApp.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
       }
       //MainWindow is derived from RibbonWindow
       WpfRibbonApplication1.MainWindow window = new WpfRibbonApplication1.MainWindow();
       window.ShowDialog();
    
    

    Everything including closing MainWindow seems works fine until I close Word. When closing Word, Word crashed with the following error:

    Problem signature:
      Problem Event Name: CLR20r3
      Problem Signature 01: winword.exe
      Problem Signature 02: 12.0.4518.1014
      Problem Signature 03: 45428028
      OS Version: 6.1.7600.2.0.0.256.1
      Locale ID: 1033

    Additional information about the problem:
      LCID: 1033
      Brand: Office12Crash
      skulcid: 1033

    Read our privacy statement online:
      http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

    If the online privacy statement is not available, please read our privacy statement offline:
      C:\Windows\system32\en-US\erofflps.txt

     However if I replace MainWindow with Window1 which derives from Window and contains no Ribbon, the crash won't happen. So I think Ribbon/RibbonWindow causes Word's crash. BTW, I didn't see any problem when I use WPF Ribbon preview version.

    Any suggestion? Thanks in advance.

    Thursday, August 19, 2010 3:34 AM

Answers

  • Hi Avery,

    I did some research for it, and the AppDomain of the addin did not close when user close the RibbonWindow. From the source code of the RibbonWindow, the close button invoke the SystemCommands.CloseWindow command; It is different with the ApplicationCommands.Close command. You could refer to the source code of Ribbon library: http://www.microsoft.com/downloads/details.aspx?FamilyID=2BFC3187-74AA-4154-A670-76EF8BC2A0B4&displaylang=en

    In general, the window close action should trigger the application shutdown, but here, the RibbonWindow does not.(I will continue to do the research). That is why we double click the RibbonWindow icon and cannot close the Window, it thorws an exception "System.EntryPointNotFoundException ..." when it try to close the application.

    However, there is a workaround for it. Adding some code in the addin close to shut down the application, such as:

      private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
      {
       Dispatcher.CurrentDispatcher.InvokeShutdown();
      }
    
    

    in the ThisAddIn class.

    I will continue to focus this issue, hope it helps.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Avery_wu Wednesday, August 25, 2010 5:53 AM
    Wednesday, August 25, 2010 3:07 AM
  • Hi,

    Continue ...

    The ribbon window run in the Addin appdomain, and the window try call Application.Current.Shutdown(); in its close command. But here the Application.Current is null, it thows that exception. However, if we create an Application for running the RibbonWindow, once the window closed, the application for it has been shut down. Then we cannot run the application again (cannot open the window again).

    So summary, shut down the CurrentDispatcher for the RibbonWindow at the Addin shutdown event is the correct pattern for the RibbonWindow as the Addin.

    Sincerely,

    Bob Bao

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Avery_wu Wednesday, August 25, 2010 5:54 AM
    Wednesday, August 25, 2010 3:39 AM

All replies

  • I developed a simple Word 2007 addin using VS 2010 VSTO, in the addin I simply want to display WPF RibbonWindow like this:

          if (WpfApp == null)
          {
            //I get same result when deleteing the following two lines
            WpfApp = new System.Windows.Application();
            WpfApp.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
          }
          //MainWindow is derived from RibbonWindow
          WpfRibbonApplication1.MainWindow window = new WpfRibbonApplication1.MainWindow();
          window.ShowDialog();
    
    

    Everything including closing MainWindow seems working fine until I close Word. When closing Word, Word crashed with the following error:

    Problem signature:
      Problem Event Name: CLR20r3
      Problem Signature 01: winword.exe
      Problem Signature 02: 12.0.4518.1014
      Problem Signature 03: 45428028
      OS Version: 6.1.7600.2.0.0.256.1
      Locale ID: 1033

    Additional information about the problem:
      LCID: 1033
      Brand: Office12Crash
      skulcid: 1033

    Read our privacy statement online:
      http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

    If the online privacy statement is not available, please read our privacy statement offline:
      C:\Windows\system32\en-US\erofflps.txt

     However if I replace MainWindow with Window1 which derives from Window and contains no Ribbon, the crash won't happen. So I think Ribbon/RibbonWindow causes Word's crash. BTW, I didn't see any problem when I use WPF Ribbon preview version.

    Any suggestion? Thanks in advance.

    Wednesday, August 18, 2010 1:53 PM
  • Hi Avery_wu,

    clr20r3 is just a general event message showing that there is an unhandled exception in the application. The Windows logs server can log this unhandled exception, please check it in the "Computer Management>Event Viewer". And meanwhile, you could try to handle the AppDomain.CurrentDomain.UnhandledException event in your application and catch this exception. Another way to get the information about this exception - using Windbg. Please follow this blog and try to get more information about this exception : http://blogs.msdn.com/b/msdnts/archive/2006/11/24/how-to-debug-application-crash-hang-in-production-environment.aspx that can help us to analyze its cause.

    Sincerely,

    Bob Bao

    MSDN Subscriber Support in Forum 

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, August 20, 2010 2:14 AM
  •  I appreciate your help.

    1. AppDomain.UnhandleException couldn't catch the exception;

    2. I use WinDbg get the following info, I don't understand what this means:
    0:017> g
    ModLoad: 61240000 61253000   C:\WINDOWS\system32\msctfp.dll
    (718.460): C++ EH exception - code e06d7363 (first chance)
    (718.460): CLR exception - code e0434f4d (first chance)
    (718.460): CLR exception - code e0434f4d (!!! second chance !!!)
    eax=0012ce94 ebx=e0434f4d ecx=00000000 edx=00000028 esi=0012cf20 edi=00167860
    eip=77e4bef7 esp=0012ce90 ebp=0012cee4 iopl=0         nv up ei pl nz na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
    kernel32!RaiseException+0x53:
    77e4bef7 5e              pop     esi
    Missing image name, possible paged-out or corrupt data.
    Missing image name, possible paged-out or corrupt data.
    Missing image name, possible paged-out or corrupt data.
    0:000> kb
    ChildEBP RetAddr  Args to Child             
    0012cee4 79ef2bbc e0434f4d 00000001 00000001 kernel32!RaiseException+0x53
    0012cf44 79f51c64 039dfd00 00000000 00000000 mscorwks!RaiseTheExceptionInternalOnly+0x2a8
    0012cf7c 7a0c9800 ffffffff 070a39a8 4b49ac2f mscorwks!UnwindAndContinueRethrowHelperAfterCatch+0x70
    0012cfd0 0169a91a ffffffff 00167860 0012d000 mscorwks!UM2MDoADCallBack+0xb7
    WARNING: Frame IP not in any known module. Following frames may be wrong.
    0012cff8 7739b6e3 00040662 0000001c 00000000 <Unloaded_onControlsLibrary.DLL>+0x169a8d9
    0012d024 7739b874 0169d472 00040662 0000001c USER32!InternalCallWinProc+0x28
    0012d09c 7739c8b8 00000000 0169d472 00040662 USER32!UserCallWinProcCheckWow+0x151
    0012d0f8 7739c9c6 0066a428 0000001c 00000000 USER32!DispatchClientMessage+0xd9
    0012d120 7c828556 0012d138 00000018 0012f77c USER32!__fnDWORD+0x24
    0012d14c 7738b993 3137ac00 001004fa 00000000 ntdll!KiUserCallbackDispatcher+0x2e
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files\Microsoft Office\Office12\wwlib.dll -
    0012d194 31255a14 001004fa 00000011 0012f760 USER32!NtUserDestroyWindow+0xc
    0012f6e8 7739b6e3 001004fa 00000010 00000011 wwlib!DllGetClassObject+0x10dca
    0012f714 7739b874 31255694 001004fa 00000010 USER32!InternalCallWinProc+0x28
    0012f78c 7739bfce 00000000 31255694 001004fa USER32!UserCallWinProcCheckWow+0x151
    0012f7bc 7739bf74 31255694 001004fa 00000010 USER32!CallWindowProcAorW+0x98
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office12\mso.dll -
    0012f7dc 32650bae 31255694 001004fa 00000010 USER32!CallWindowProcW+0x1b
    0012f814 7739b6e3 006e0fc0 00000010 00000011 mso!Ordinal669+0x37c
    0012f840 7739b874 016e0fc0 001004fa 00000010 USER32!InternalCallWinProc+0x28
    0012f8b8 7739ba92 00000000 016e0fc0 001004fa USER32!UserCallWinProcCheckWow+0x151
    0012f920 7739bad0 320a6900 00000000 0012f940 USER32!DispatchMessageWorker+0x327

    3. Event viewer doesn't contain helpful infomation:

    - System

       
    - Provider
          [ Name] Microsoft Office 12
       
    - EventID 2000
          [ Qualifiers] 0
       
      Level 2
       
      Task 0
       
      Keywords 0x80000000000000
       
    - TimeCreated
          [ SystemTime] 2010-08-20T01:46:33.000000000Z
       
      EventRecordID 8195
       
      Channel Application
       
      Computer wry-PC
       
      Security

    - EventData

        Microsoft Office Excel
        Excel experienced a serious problem with the 'exceladdin1' add-in. If you have seen this message multiple times, you should disable this add-in and check to see if an update is available. Do you want to disable this add-in?

     

    Thanks.

    Friday, August 20, 2010 2:45 AM
  • Hi Avery_wu,

    You could load the Sos model in the Windbg and try to get the unhandled exception on the correct thread by the command: !pe (!PrintException). Or you could try to create a dump of this crash and we can help you to analyze it.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, August 20, 2010 6:26 AM
  • Hi Bob,

    Thanks for your reply.

    I try SOS and !pe,  but seems no lucky. The fullmemory minidump file is about 280MB, is there a feasible way to send it to you?


    I don't know if basic minidump would help.You may login into RibbonIssue@gmail.com with password Ribbon.Issue to get dump file:
    In the draft folder you may find an email with 2 attached files:
    1. winwordmini.dmp is the basic minidump file;
    2. wordAddIn2.zip is the minimum VS 2010 solution which can repro the issue. You can build it if you have VS2010+Office 2007 installed; after building  you can debug it or open word directly, then click Add-Ins Tab->click Wpf button->MainWindows displayed->Close MainWindow->Close Word->Word crash...

    Best Regards,
    Avery

    Friday, August 20, 2010 8:11 AM
  • Hi Bob,

    I debugged this addin based on Word 2010 today, and got clearer info:

    0:000> !analyze -v
    *******************************************************************************
    *                                       *
    *            Exception Analysis                  *
    *                                       *
    *******************************************************************************
    
    GetPageUrlData failed, server returned HTTP status 404
    URL requested: http://watson.microsoft.com/StageOne/WINWORD_EXE/14_0_4762_1000/4bae25b7/ntdll_dll/6_1_7600_16385/4a5bdadb/e0434f4d/000464f4.htm?Retriage=1
    
    FAULTING_IP: 
    ntdll!KiFastSystemCallRet+0
    76ed64f4 c3       ret
    
    EXCEPTION_RECORD: 0016a884 -- (.exr 0x16a884)
    ExceptionAddress: 75299617 (KERNELBASE!RaiseException+0x00000058)
      ExceptionCode: e0434352 (CLR exception)
     ExceptionFlags: 00000001
    NumberParameters: 5
      Parameter[0]: 80131014
      Parameter[1]: 00000000
      Parameter[2]: 00000000
      Parameter[3]: 00000000
      Parameter[4]: 6dab0000
    
    PROCESS_NAME: WINWORD.EXE
    
    ERROR_CODE: (NTSTATUS) 0xe0434f4d - <Unable to get error code text>
    
    EXCEPTION_CODE: (NTSTATUS) 0xe0434f4d - <Unable to get error code text>
    
    MOD_LIST: <ANALYSIS/>
    
    NTGLOBALFLAG: 0
    
    APPLICATION_VERIFIER_FLAGS: 0
    
    MANAGED_STACK: !dumpstack -EE
    OS Thread Id: 0xb2c (0)
    Current frame: 
    ChildEBP RetAddr Caller, Callee
    
    EXCEPTION_OBJECT: !pe 542b3e8
    Exception object: 0542b3e8
    Exception type:  System.AppDomainUnloadedException
    Message:     Attempted to access an unloaded AppDomain.
    InnerException:  <none>
    StackTrace (generated):
    <none>
    StackTraceString: <none>
    HResult: 80131014
    
    MANAGED_OBJECT: !dumpobj 542b544
    Name:    System.String
    MethodTable: 6c3ef9ac
    EEClass:   6c128bb0
    Size:    98(0x62) bytes
    File:    C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
    String:   Attempted to access an unloaded AppDomain.
    Fields:
       MT  Field  Offset         Type VT   Attr  Value Name
    6c3f2978 40000ed    4     System.Int32 1 instance    42 m_stringLength
    6c3f1dc8 40000ee    8     System.Char 1 instance    41 m_firstChar
    6c3ef9ac 40000ef    8    System.String 0  shared  static Empty
      >> Domain:Value 0027ef88:05111228 04d81980:05111228 <<
    
    EXCEPTION_MESSAGE: Attempted to access an unloaded AppDomain.
    
    MANAGED_OBJECT_NAME: System.AppDomainUnloadedException
    
    CONTEXT: 0016a8ac -- (.cxr 0x16a8ac)
    eax=0016ab90 ebx=00000005 ecx=00000005 edx=00000000 esi=0016ac3c edi=04d1b178
    eip=75299617 esp=0016ab90 ebp=0016abe0 iopl=0     nv up ei pl nz ac pe nc
    cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000       efl=00000216
    KERNELBASE!RaiseException+0x58:
    75299617 c9       leave
    Resetting default scope
    
    FAULTING_THREAD: 00000b2c
    
    DEFAULT_BUCKET_ID: CLR_EXCEPTION
    
    PRIMARY_PROBLEM_CLASS: CLR_EXCEPTION
    
    BUGCHECK_STR: APPLICATION_FAULT_CLR_EXCEPTION_WRONG_SYMBOLS__SYSTEM.APPDOMAINUNLOADEDEXCEPTION
    
    LAST_CONTROL_TRANSFER: from 6db3ac08 to 75299617
    
    STACK_TEXT: 
    0016abe0 6db3ac08 e0434352 00000001 00000005 KERNELBASE!RaiseException+0x58
    0016ac70 6dbaab0b 0542b3e8 00000000 00000000 clr!RaiseTheExceptionInternalOnly+0x276
    0016acac 6dd7f268 ffffffff 07e57848 c844d2ab clr!UnwindAndContinueRethrowHelperAfterCatch+0x60
    0016acf8 04ee03c6 00000000 ffffffff 0016ad34 clr!UM2MDoADCallBack+0xfa
    WARNING: Frame IP not in any known module. Following frames may be wrong.
    0016ad2c 75b686ef 000c0494 0000001c 00000000 0x4ee03c6
    0016ad58 75b68876 04ede75a 000c0494 0000001c user32!InternalCallWinProc+0x23
    0016add0 75b670f4 00000000 04ede75a 000c0494 user32!UserCallWinProcCheckWow+0x14b
    0016ae2c 75b6738f 00645b98 0000001c 00000000 user32!DispatchClientMessage+0xda
    0016ae54 76ed642e 0016ae6c 00000018 0016d44c user32!__fnDWORD+0x24
    0016ae80 75b5d5fb 5045fd73 000606f2 00000001 ntdll!KiUserCallbackDispatcher+0x2e
    0016ae84 5045fd73 000606f2 00000001 00000000 user32!NtUserDestroyWindow+0xc
    0016aecc 50235460 000606f2 00000011 0016d4d8 WWLIB!DllGetLCID+0x3237d
    0016d41c 502350a5 000606f2 00000010 00000011 WWLIB!DllGetClassObject+0xfe84
    0016d45c 75b686ef 000606f2 00000010 00000011 WWLIB!DllGetClassObject+0xfac9
    0016d488 75b68876 50235064 000606f2 00000010 user32!InternalCallWinProc+0x23
    0016d500 75b643cf 00000000 50235064 000606f2 user32!UserCallWinProcCheckWow+0x14b
    0016d530 75b643f5 50235064 000606f2 00000010 user32!CallWindowProcAorW+0x99
    0016d550 73f1450e 50235064 000606f2 00000010 user32!CallWindowProcW+0x1b
    0016d56c 73f1463d 000606f2 00000010 00000011 comctl32_73ee0000!CallOriginalWndProc+0x1a
    0016d5d0 73f145f1 001b1850 000606f2 00000010 comctl32_73ee0000!CallNextSubclassProc+0x3d
    0016d5f4 38cbdbaf 000606f2 00000010 00000011 comctl32_73ee0000!DefSubclassProc+0x46
    0016d63c 38cbd800 000606f2 00000010 00000011 MSO!Ordinal1888+0x38e
    0016d668 73f1463d 000606f2 00000010 00000011 MSO!Ordinal4894+0x24b
    0016d6cc 73f146e1 001b1850 000606f2 00000010 comctl32_73ee0000!CallNextSubclassProc+0x3d
    0016d72c 75b686ef 000606f2 00000010 00000011 comctl32_73ee0000!MasterSubclassProc+0x54
    0016d758 75b68876 73f1469d 000606f2 00000010 user32!InternalCallWinProc+0x23
    0016d7d0 75b689b5 00000000 73f1469d 000606f2 user32!UserCallWinProcCheckWow+0x14b
    0016d830 75b68e9c 73f1469d 00000000 0016d850 user32!DispatchMessageWorker+0x35e
    0016d840 50282690 511096a0 511096a0 0016d868 user32!DispatchMessageW+0xf
    0016d850 50489f30 511096a0 75b64fda 511096a0 WWLIB!GetAllocCounters+0x4b8c8
    0016d868 50282163 00000001 0121008c 01210000 WWLIB!DllGetLCID+0x5c53a
    0016d890 502813e6 50220000 75c71857 502250f7 WWLIB!GetAllocCounters+0x4b39b
    0016fa00 2f041602 2f040000 00000000 001b2ba1 WWLIB!GetAllocCounters+0x4a61e
    0016fa24 2f04159a 2f040000 00000000 001b2ba1 WINWORD+0x1602
    0016fab4 75c71194 7ffdf000 0016fb00 76eeb3f5 WINWORD+0x159a
    0016fac0 76eeb3f5 7ffdf000 784cd85e 00000000 kernel32!BaseThreadInitThunk+0xe
    0016fb00 76eeb3c8 2f0410ec 7ffdf000 ffffffff ntdll!__RtlUserThreadStart+0x70
    0016fb18 00000000 2f0410ec 7ffdf000 00000000 ntdll!_RtlUserThreadStart+0x1b
    
    
    FOLLOWUP_IP: 
    clr!RaiseTheExceptionInternalOnly+276
    6db3ac08 c745fcfeffffff mov   dword ptr [ebp-4],0FFFFFFFEh
    
    SYMBOL_STACK_INDEX: 1
    
    SYMBOL_NAME: clr!RaiseTheExceptionInternalOnly+276
    
    FOLLOWUP_NAME: MachineOwner
    
    MODULE_NAME: clr
    
    IMAGE_NAME: clr.dll
    
    DEBUG_FLR_IMAGE_TIMESTAMP: 4ba1d9ef
    
    STACK_COMMAND: dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; .cxr 0x16a8ac ; kb
    
    FAILURE_BUCKET_ID: CLR_EXCEPTION_e0434f4d_clr.dll!RaiseTheExceptionInternalOnly
    
    BUCKET_ID: APPLICATION_FAULT_CLR_EXCEPTION_WRONG_SYMBOLS__SYSTEM.APPDOMAINUNLOADEDEXCEPTION_clr!RaiseTheExceptionInternalOnly+276
    
    WATSON_STAGEONE_URL: http://watson.microsoft.com/StageOne/WINWORD_EXE/14_0_4762_1000/4bae25b7/ntdll_dll/6_1_7600_16385/4a5bdadb/e0434f4d/000464f4.htm?Retriage=1
    
    Followup: MachineOwner
    

     Please help, thanks.

    Best Regards,
    Avery

    Monday, August 23, 2010 4:57 AM
  • Hi Avery,

    I did some research for it, and the AppDomain of the addin did not close when user close the RibbonWindow. From the source code of the RibbonWindow, the close button invoke the SystemCommands.CloseWindow command; It is different with the ApplicationCommands.Close command. You could refer to the source code of Ribbon library: http://www.microsoft.com/downloads/details.aspx?FamilyID=2BFC3187-74AA-4154-A670-76EF8BC2A0B4&displaylang=en

    In general, the window close action should trigger the application shutdown, but here, the RibbonWindow does not.(I will continue to do the research). That is why we double click the RibbonWindow icon and cannot close the Window, it thorws an exception "System.EntryPointNotFoundException ..." when it try to close the application.

    However, there is a workaround for it. Adding some code in the addin close to shut down the application, such as:

      private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
      {
       Dispatcher.CurrentDispatcher.InvokeShutdown();
      }
    
    

    in the ThisAddIn class.

    I will continue to focus this issue, hope it helps.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Avery_wu Wednesday, August 25, 2010 5:53 AM
    Wednesday, August 25, 2010 3:07 AM
  • Hi,

    Continue ...

    The ribbon window run in the Addin appdomain, and the window try call Application.Current.Shutdown(); in its close command. But here the Application.Current is null, it thows that exception. However, if we create an Application for running the RibbonWindow, once the window closed, the application for it has been shut down. Then we cannot run the application again (cannot open the window again).

    So summary, shut down the CurrentDispatcher for the RibbonWindow at the Addin shutdown event is the correct pattern for the RibbonWindow as the Addin.

    Sincerely,

    Bob Bao

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Avery_wu Wednesday, August 25, 2010 5:54 AM
    Wednesday, August 25, 2010 3:39 AM
  • Bob,

          You're champion! InvokeShutdown() resolves my problem.

          Just for discussion purpose: AppDoaminUnloadedException is thrown even when I use Ribbon directly, i.e. define Ribbon within Window instead of RibbonWindow. In my opinion, Dispatcher was used intensively in Ribbon, dispatcher is still running after addin/domain is shut down/unloaded.

    Thanks again.

    Avery

    Wednesday, August 25, 2010 5:53 AM