Hi,
 
The assertion  was in ..\OLEDOC1.CPP in CDocItem::Serialize(CArchive& ar) function in line 816. The problem was that ar.m_pDocument was NULL.
I fixed with by simply attaching my document to the CArchive object:
ar.m_pDocument = (COleDocument*)this;  
I had also to set CDocument::m_bCompound to false. It seems that everything works fine now :-)
 
I have another question though:
Is it possible to use a CMemFile to serialize the OLE objects into memory?  What I'd like to do is to serialize the objects to the memory and then perform some operations (e.g. write the memory contents in another file, in this case in an XML file encoded in Base64). This is what I'm trying:
 
CMemFile mf;
  CArchive ar( &mf, CArchive::store );
  COleServerDoc::Serialize(ar);
  mf.SeekToBegin();
  int nSize = mf.GetLength();
  BYTE* pBuffer = mf.Detach();
  CString csBase64;
  csBase64 = CMarkup::EncodeBase64( pBuffer, nSize);
  
  xml.AddChildElem("Values", csBase64);
  ar.Close();
 
This asserts when the memory file object (mf) gets out of scope or when ar.Close() is called. The assertion is in CMemFile::AssertValid(), exactly in the following line:
 
ASSERT(m_nFileSize <= m_nBufferSize);
 
Any idea?
 
Thanks,
Carlos
 
 
----- Original Message -----
Sent: Tuesday, December 16, 2003 7:20 PM
Subject: RE: [msvc] Problem with serialization

 

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?
What line it's asserting on?

---------
Ehsan Akhgari

List Owner: [EMAIL PROTECTED]

[Email: [EMAIL PROTECTED]]
[WWW: http://www.beginthread.com/Ehsan ]

Ideas that fall under shadows of theories that stand tall, thoughts that grow narrow upon being verbally released.


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

Reply via email to