I found the problem ... For those interested, this is the solution:
 
TRY
    {   
     CFile fil( (LPCTSTR)str, CFile::modeRead );
     CArchive ar( &fil, CArchive::load, 4096); 
     m_bCompoundFile = false;                // ---> This and the next line did the trick
     ar.m_pDocument = (COleDocument*)this;  
    
     COleServerDoc::Serialize(ar);
    }
    CATCH( CFileException, e )
    {   
     AfxMessageBox("Cannot open ole file");
    }
    END_CATCH
----- Original Message -----
Sent: Tuesday, December 16, 2003 2:26 PM
Subject: [msvc] Problem 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 is properly saved, but when I try to load it, I get a debug assertion when COleServerDoc::Serialize(ar) is called.
 
What I'm doing wrong?
 
Thanks,
Carlos
 
 
 


_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.

Reply via email to