Re: [Boost-users] Exception when reading from an archive

--- Eyal Susser <eyal.susser@gmail.com> wrote:
Hi, I'm using the serialization library, but have encountered problems.
I have an archiver that I use with a stringstream to serialize objects. I write some ints to the archive using "ar << my_int", and finally I archive a derived class wi ar << derived. So far, so good.
In a different process, I create an input archiver, read the integers, and then pass the archiver to a different method, where I create an instance of the class I serialized and use "ar >> instance". This throws an exception.
The code for the object created is one *.so, and teh code that does the creating does it with a templated class factory in a different *.so. Is that why I'm gettin the exceptions? Is there a solution?
The exception is boost::archive::archive_exception what(): stream error.
Thanks.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Are you registering all your classes you are serializing? Your input archiver may not know about all class types in your archive. Use the macro BOOST_CLASS_EXPORT(ClassName) to export a GUID for every class. This should be in a .cpp file outside of any functions. include <boost/serialization/export.hpp> to use it. This include should be placed after any archiver includes. Also within your class (if it is a container for other classes) you will need to do this in your serialize function: ar.register_type(static_cast<ClassName*>(NULL)); // if they are pointers Have fun, -K __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (1)
-
kauai