Note that there are some explanatory texts on larger screens.

plurals
  1. POSerializing a Pointer using MFC CArchive (with mfc100d.dll, CMemFile)
    text
    copied!<p>I am running into an issue serializing and deserializing pointer data in VS2010 VC++. Basically, the program was unable to serialize and deserialize a CObList * pointer data. The source code does the normal steps to handle the process:</p> <p>1) MyObject was inherited from CObject;</p> <p>2) We added DECLARE_SERIAL(MyObject) in the class declaration (1st line);</p> <p>3) We added IMPLEMENT_SERIAL( MyObject, MyParentObject, SCHEMA_VERSION )</p> <pre><code>//Where MyParentObject is inherited from CObject (indirectly, there're a few more levels of objects), SCHEMA_VERSION is just a version control CONSTANT we use </code></pre> <p>4) Then we have overloaded</p> <pre><code>void MyObject::Serialize( CArchive&amp; ar ) { BOOL b; ..... ... (some other simple variables with default values) MyParentObject::Serialize(ar); if (ar.IsStoring()) { ar &lt;&lt; m_sTitle; ar &lt;&lt; m_pObjectsList; } else { ar &gt;&gt; m_sTitle; ar &gt;&gt; m_pObjectsList; } } </code></pre> <p>Note: MyParentObject::Serialize is implemented accordingly. CObList * m_pObjectsList; is declared properly in the header file.</p> <p>The program threw an Access Violation (First-chance exception at 0x52e77b2c (mfc100d.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0x00000004) when trying to deserialize from the "ar >> m_pObjectsList".</p> <p>Then I started testing and changed the complex pointer m_pObjectsList to a simple pointer to CString. Same error occur at the same time when deserializing the pointer to CString. If I simply serialize and deserialize by CString (without the pointer), it works fine. It seems like some pointer serializing is broken.</p> <p>Maybe MFC100d doesn't work well with W32 program in a 64Bit OS Debugger? This is causing problem both in Debug mode and Release mode. What's happening? I've exhausted my resources and any direction or inspiration is much appreciated. Thank you all ahead.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload