question

MichaelDudenhffer-2786 avatar image
0 Votes"
MichaelDudenhffer-2786 asked Webdev-3920 commented

Crash after Office Update Version 2109 (Build 14430.20234)

Hi,

I have a MFC-based OLE application which is loading MS-Excel in an embedded OLE container. This worked fine for years. But after installing the Office Update mentioned above in the subject the application is crashing, yet.

The function XDocumentSite::ActivateMe does the following steps:

  1. Create a view for the embedded document

    if (NULL==pView)
    {

          if (FAILED(pThis->m_lpObject->QueryInterface(IID_IOleDocument, (void **)&pDoc)))
                 return E_FAIL;
                
             if (FAILED(pDoc->CreateView(&pThis->m_xOleIPSite, 0, 0, &pView)))            
                 return E_OUTOFMEMORY;
                
             // Release doc pointer since CreateView is a good com method that addrefs
             pDoc->Release();
         }
    

  2. Initialize the UI of the view.

    pView->UIActivate(TRUE);

  3. Set the view rectangle.

    pThis->GetActiveView()->GetClientRect(rc);
    pView->SetRect(&rc);

  4. Show the view (make it visible).

    pView->Show(TRUE);

Steps 1. and 2. are working as expected. The problem is step 3: the GetActiveView() method is returning a NULL pointer. But I don't know why.

I made a Visual Studio solution example (VS 2019) with which the error can be reproduced reliably.

Does anyone know this problem or can help investigate?

Best Regards,
Michael

windows-apioffice-vba-devoffice-excel-itprooffice-scripts-excel-dev
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Michael, you are right. I can confirm, the problem could be easily reproduced with the MFC/OLE default reference example MFCBind and Excel versions equal and newer then 14430.20234. Previous versions work fine. There must be an breaking change. I have compiled it also with VS 2019.



1 Vote 1 ·

Does no one know a forum or a responsible person to the problem with the latest versions of Excel?

1 Vote 1 ·

What is pThis in pThis->GetActiveView( )?


0 Votes 0 ·

Thanks for your reply!

pThis is generated through the METHOD_PROLOGUE function at the beginning of ActivateMe():

 STDMETHODIMP COACntrItem::XDocumentSite::ActivateMe(IOleDocumentView *pView)
 {
     METHOD_PROLOGUE(COACntrItem, DocumentSite)

     ...    
    
     //Set the window size sensitive to new toolbars
     pThis->GetActiveView()->GetClientRect(rc);
     pView->SetRect(&rc);
    
     //Makes it all active
     pView->Show(TRUE);
     return NOERROR;
 }

It's an MFC macro setting up a local variable "pThis":

 #define METHOD_PROLOGUE(theClass, localClass) \
     theClass* pThis = \
         ((theClass*)((BYTE*)this - offsetof(theClass, m_x##localClass))); \
     AFX_MANAGE_STATE(pThis->m_pModuleState) \
     pThis; // avoid warning from compiler \

pThis is of type COACntrItem which is derived from MFC class cOleClientItem:

 class COACntrItem : public COleClientItem
 {
     friend class COAView;
    
     DECLARE_SERIAL(COACntrItem)
     ...
 }


0 Votes 0 ·

Any suggestions?

0 Votes 0 ·

1 Answer

emilyhua-msft avatar image
0 Votes"
emilyhua-msft answered MichaelDudenhffer-2786 commented

@MichaelDudenhffer-2786
Welcome to Q&A forum ~
But please note, the tag "office-excel-itpro" focus more on general issue of Excel client, but your issue Involves the code, which is out of my support scope.
Thanks for your understanding.
To better help you, I would add some other tags, hope that some experts with code experience can provide better help.

From the perspective of Office client, you can try to rollback Office version.
"C:\Program Files\Common Files\microsoft shared\ClickToRun\officec2rclient.exe" /update user updatetoversion=16.0.XXXXX.XXXXX
Please note, the command if for 64-bit version. "XXXXX.XXXXX" mean the version number, such as for Microsoft 365 apps, you could roll back to version 14326.20404.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your answer!

My original intention was to create the question under "Component development (COM, DCOM, and COM+)" section (https://docs.microsoft.com/en-us/answers/topics/windows-api-com.html). How can I move it there?

Regarding your hint to rollback Office: this was my original way, how I found, which office version crashes our application. In general this is not a solution for me, because of security fixes and new features of Microsoft Office would lack over time.

1 Vote 1 ·