How to store CObArray object arrays in file (Serialize problem)

i want to store recode in file. It is a simple file-based database, with the records sequentially appended to the end of the previous record.

So firstly i made Recde Class , this class object store recode and every recode add in CObArray object arrays ....

but problem ocurse when i want store in file bcoz CObArray object arrays not store in file i am using Serialize but get error when stroring in file...

CArchive ar(&file, CArchive::store);

UpdateData(TRUE);
Recode->SetName(m_Name); // Recode of one person
Recode->SetValue(m_value); // Recode of one person

m_oaPeople.Add(Recode);

//Recode store in CObArray object arrays
m_oaPeople.Serialize(ar); // Here have problem

Guide me




Answer this question

How to store CObArray object arrays in file (Serialize problem)

  • RaptorAvis

    This ASSERT is fired when you class has no DECLARE_SERIAL/IMPLEMENT_SERIAL! I mentioned this in my previous answers!

    The schema number is 0xFFFF. Because I see the classname CObject I can see that there is no DECLARE_.../IMPLEMENT_... macro defined for this class at all!

    Show the declaration and definition of the class you want to serialize!



  • Andre Scaravelli

    What error Please try to be more precisise.

    Check the Debug output for information. A lot of infos about problems causes a trace message to appear in the Debug Output Window.



  • Gogula

    What do you mean does not work properly
    When you call Serialize what happens
    Give us some code, that we can see what might the fault!



  • Voxen

    CArchive ar(&file, CArchive::store);

    UpdateData(TRUE);
    Recode->SetName(m_Name); // Recode of one person
    Recode->SetValue(m_value); // Recode of one person

    m_oaPeople.Add(Recode);

    //Recode store in CObArray object arrays means (m_oaPeople)


    m_oaPeople.Serialize(ar); // Here have problem this funtion genrate error at runtime



  • Zhisheng Huang - MSFT

    Thank for fast response

    i have alrady done this work means

    Recode class derived from CObject

    and IMPLEMENT_SERIAL , DECLARE on Recode class

    Thhis recode object store in CObArray Object and run time these recode acsess by Index menas

    Object [ n ]         n= 1,2..........n  n = Totle No of Recode

    i want to store these recodes in file  , CObArray Object have recodes so CObArray Object store in file bcoz CObArray class have serialize funtion but this funtion not working properly

     

    Book :- Teach Yourself Visual C++ In 21 Days

     Caphter :-  DAY 13 WEEK 2 Saving and Restoring Work—File Access

     This caphter have exmple, which is simle  to my project but here auother use SDI application means "The Document/View Architecture.”  but i am working with Dialog   base Application

    Yogesh Kumar Dhiman [Software Engg.]

     

     



  • ckris

    my code run thank sir for this information .........

    sir thank to u

    problem in IMPLEMENT_... macro defined by mistake this remove in code . but i have used in code this workig with recode object . but when i was run with CObArray object arrays so problem ocures...

    thank sir



  • Jaziel

    1. Did you derived your recode class from CObject

    2. Did you used IMPLEMENT_SERIAL and DECLARE_SERIAL on that class



  • Exclusive

    Debub window content

    Warning: Cannot call WriteClass/WriteObject for CObject.
    First-chance exception in TestSerilazation.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

    //------------------------------------------------------------------

    Dialog Box appare on Moniter

    ERROR : (><) An unsuppotted opration was attempted.



  • How to store CObArray object arrays in file (Serialize problem)