
Double check that the stream is opened with ios::binary. This is a common gotcha that shows up in this circumstance. Robert Ramey Terence Wilson wrote:
I've been scratching my head trying to figure this one out for a few days. My code serializes xml_iarchive & text_iarchive with no problems, however, when I substitute the binary_iarchive I get a "stream error" serialization exception thrown during the make_binary_object call when reading a binary file:
template<class Archive> void serialize(Archive & ar, const unsigned int) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(CImageDataBase2D);
if (Archive::is_loading::value) { Alloc(); }
//ar & boost::serialization::make_nvp("ImageData", boost::serialization::make_binary_object(m_pData, sizeof(T)*m_x*m_y));
const int blobSize=sizeof(T)*m_x*m_y; _ASSERTE(blobSize); ar & boost::serialization::make_nvp("ImageData", boost::serialization::make_binary_object(m_pData, blobSize)); }
I've tried to excise the relevant code to a console project, however, it has tentacles and will take a few more days. In the mean time I would appreciate help from anyone that might have a suggestion.
I've looked at the code and can find nothing wrong, as I said, ASCII and XML serialization works flawlessly
I'm using Visual Studio 8 with Boost 1.33.1.