
pipalapop wrote:
Hi, I have a problem with the deserialization of objects defined in multiple dlls. I define the following classes in a first dll: polymorphic_base (pure virtual) and polymorphic_derived1 (derived from polymorphic_base). In a second dll, I define the class polymorphic_derived2 (derived from polymorphic_derived1). In an executable, I serialize an object of type polymorphic_derived2 followed and two objects of type polymorphic_derived1 in the order defined in this function:
void save_exported (const char *testfile) { std::ofstream os(testfile); xml_oarchive oa(os);
polymorphic_base * pb_ptr_1 = new polymorphic_derived1; oa << BOOST_SERIALIZATION_NVP(pb_ptr_1);
polymorphic_base * pb_ptr_2 = new polymorphic_derived2; oa << BOOST_SERIALIZATION_NVP(pb_ptr_2);
polymorphic_base * pb_ptr_3 = new polymorphic_derived1; oa << BOOST_SERIALIZATION_NVP(pb_ptr_3);
}
The serialization works, but when, I try to deserialyze with this function:
void load_exported(const char *testfile) { std::ifstream is(testfile); xml_iarchive ia(is);
polymorphic_base * pb_ptr_1 = NULL; ia >> BOOST_SERIALIZATION_NVP(pb_ptr_1);
polymorphic_base * pb_ptr_2 = NULL; ia >> BOOST_SERIALIZATION_NVP(pb_ptr_2);
polymorphic_base * pb_ptr_3 = NULL; ia >> BOOST_SERIALIZATION_NVP(pb_ptr_3); // <= exception
}
an exception is thrown on the deserialization of the second object of type polymorphic_derived1 but it works for the first one.
in the file basic_archive.cpp, line 466 : "pending_bis = & bpis_ptr->get_basic_serializer();" bpis_ptr is null.
It seems that the deserialization of the object of type polymorphic_derived2 (derived from polymorphic_derived1) has broken the part of table cobject_id_vector concerning polymorphic_derived1.
If polymorphic_derived2 is defined in the first dll, there is no problem.
Is it possible to make it works with 2 dll?
probably, but would required some investigation. Robert Ramey
Regards, Yohan
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost