BUG: Serialize in MFC Container-Server Applications May FailLast reviewed: July 18, 1997Article ID: Q111770 |
1.50 1.51 1.52
WINDOWS
kbprg kbbuglist
The information in this article applies to:
SYMPTOMSIn an AppWizard-generated OLE (Object Linking and Embedding) 2.0 container- server application, when saving a container-server embedded object that contains another embedded object, the following assertions may occur:
OLECLI1.CPP, Line 742 OLECLI1.CPP, Line 747These assertions indicate that the value of the COleServerDoc member variable m_bCompoundFile is incorrect for the serialization that is being attempted.
CAUSEAn MFC container-server application typically contains both a COleServerDoc derived class and a COleClientItem derived class. When a server item serializes itself, it assumes it is writing to a flat storage, which could be a file or a substorage in a compound file. This implies that m_bCompoundFile is FALSE. If the COleServerDoc member variable m_bCompoundFile is TRUE [that is, EnableCompoundFiles() has been called), its status may be changed during serialization, which could subsequently cause the serialization of embedded objects to fail.
RESOLUTIONTo work around this problem, in the COleServerDoc derived class's Serialize() member function, add logic to save and restore the state of m_bCompoundFile before and after the call to the base class Serialize() function. For example, in a container-server application where the COleServerDoc class is CConSrvDoc, add the lines marked with asterisks below:
/////////////////////////////////////////////////////////// // CConSrvDoc serialization void CConSrvDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } // Calling the base class COleServerDoc enables serialization // of the container document's COleClientItem objects. (*) BOOL bSaveCompound = m_bCompoundFile; (*) m_bCompoundFile = TRUE; COleServerDoc::Serialize(ar); (*) m_bCompoundFile = bSaveCompound; }Note that you do not need to incorporate this workaround if you have removed the "EnableCompoundFiles()" line from your document's constructor.
STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. This is not a problem in the 32-bit MFC classes.
|
Additional reference words: 1.50 2.5 2.50 2.51 2.52 assert
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |