Help with serialization
-
Hi, I have a full server/container MFC app. I'm trying to serialize the embeded OLE objects in an independent file (e.g. I don't want my document file to save the ole objects, I want them in a separate one). This is what I'm doing: //SAVE OLE OBJECTS CFile fil( "test.ole", CFile::modeWrite | CFile::modeCreate ); CArchive ar( &fil, CArchive::store ); COleServerDoc::Serialize(ar); (...) //LOAD OLE OBJECTS TRY { CFile fil( "test.ole", CFile::modeRead ); CArchive ar( &fil, CArchive::load ); COleServerDoc::Serialize(ar); } CATCH( CFileException, e ) { (...) } END_CATCH It seems that the file was properly saved, but when I try to load it, I get a debug assertion when COleServerDoc::Serialize(ar) is called. What am I doing wrong? Thanks,
-
Hi, I have a full server/container MFC app. I'm trying to serialize the embeded OLE objects in an independent file (e.g. I don't want my document file to save the ole objects, I want them in a separate one). This is what I'm doing: //SAVE OLE OBJECTS CFile fil( "test.ole", CFile::modeWrite | CFile::modeCreate ); CArchive ar( &fil, CArchive::store ); COleServerDoc::Serialize(ar); (...) //LOAD OLE OBJECTS TRY { CFile fil( "test.ole", CFile::modeRead ); CArchive ar( &fil, CArchive::load ); COleServerDoc::Serialize(ar); } CATCH( CFileException, e ) { (...) } END_CATCH It seems that the file was properly saved, but when I try to load it, I get a debug assertion when COleServerDoc::Serialize(ar) is called. What am I doing wrong? Thanks,
I fix it, these two lines did the trick: m_bCompoundFile = false; ar.m_pDocument = (COleDocument*)this;