Questions tagged [binary-serialization]

The process of translating data structures or object state into a binary format

Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.

http://en.wikipedia.org/wiki/Serialization
http://msdn.microsoft.com/en-us/library/72hyey7b(v=vs.110).aspx

178 questions
1
vote
5 answers

Is it safe to remove the const-ness of the stringstream result when performing binary serialization?

I have a situation in which I'm performing binary serialization of a some items and I'm writing them to an opaque byte buffer: int SerializeToBuffer(unsigned char* buffer) { stringstream ss; vector items = GetSerializables(); …
Kiril
  • 39,672
  • 31
  • 167
  • 226
1
vote
1 answer

Is the main purpose of object serialization in C++ for faster object loading?

I am reading code for a project written by others. The main task of the project is to read contents from a large structured text file (.txt) with 8 columns into a KnowledgeBase object, which have a number of methods and variables. The KnowledgeBase…
marlon
  • 6,029
  • 8
  • 42
  • 76
1
vote
4 answers

Customize a struct so that it serializes as a Int32

I save data using binary serialization. Now I have changed a field in the program from Int32 to a struct. But I still want to save the field as Int32 to be backward compatible. How do I do that? background information My program is ported from…
magol
  • 6,135
  • 17
  • 65
  • 120
1
vote
2 answers

Binary Serialization of multiple data types

I'm trying to serialize a struct in C++ in Visual Studio with multiple data types into binary file and de-serialize them all at once. But facing problem with memory allocation with strings while reading the data back. I know what the problem is and…
Rav
  • 75
  • 9
1
vote
2 answers

Send client side data Queue to server side through Tcp/IP

I wanna send data from client to server. There are two queues. in client side and in server side. I want to my client to be connected to the server and send all the data in client queue to the server. In server side I wanna accept all the clients…
Sency
  • 2,818
  • 8
  • 42
  • 59
1
vote
1 answer

Serializing enum-like objects

I am using binary serialization (with BinaryFormatter, etc) to serialize a graph of objects. Of those objects, some have fields of a certain type that is similar to an enumeration, except with additional properties and methods. The problem that…
Jamie
  • 3,901
  • 3
  • 23
  • 27
1
vote
2 answers

Ignore a property during serialization using BinaryFormatter only if its null

I am currently using BinaryFormatter for creating a stream. I am aware of the fact that I can mark a property with the attribute [field: NonSerialized] if I want it to be ignored by the BinaryFormatter during serialization. My question is if there…
MistyD
  • 16,373
  • 40
  • 138
  • 240
1
vote
1 answer

Exception threw out when deserializing self-reference objects while using ISerializationSurrogate

Exception threw out when I try to deserialize a self-reference object. System.Runtime.Serialization.SerializationException: "The object with ID 1 is referenced in the link address information, but the object does not exist." This is my code: class…
1
vote
0 answers

Is this a known binary format, or something home made?

I'm currently decoding a binary file format that we're using in order to do some internal analyses on the contained data. It mostly stores arrays of integers or doubles, which it stores using some kind of compression algorithm. As I'm reverse…
Erlend D.
  • 3,013
  • 6
  • 37
  • 59
1
vote
1 answer

What kind of binary data cannot be stringified to JSON?

I've read everywhere that JSON cannot encode binary data, so I wrote this simple test to check if that's actually true. function test(elem){ let reader = new FileReader ; reader.onload = ()=>{ let json =…
Seth
  • 83
  • 7
1
vote
1 answer

How to Use NodaTime with BinaryReader & BinaryWriter (.NET, C#)?

In our cross-platform multi-app networked system developed mainly with Untiy engine we use custom binary serialization that simply writes primitives using BinaryWriter and then, using mirror layout, reads the same using BinaryReader. Note that we do…
1
vote
2 answers

Example of a Customer Binary Serializer in .Net

So, I want to implement my own binary serialization. I'm looking for some examples to head me in the right direction. Also, am I better to make my own serializer class, or just implement ISerializable and use BinarySerializer? If I implement…
Kratz
  • 4,280
  • 3
  • 32
  • 55
1
vote
1 answer

Can extracting a base class break binary serialisation

If I have a class with a number of fields, and I serialise it using binary serialisation. I then extract a base class and move some of the fields from the class into the base class. Eg. class Class { int field1; string field2; } Is…
Yair Halberstadt
  • 5,733
  • 28
  • 60
1
vote
0 answers

BinaryFormatter Serialize excludes datatable.defaultview.sort property during serilization

I have a class with multiple properties, some of property type in class is datatable I am using BinaryFormatter to create a clone copy of class, it works fine but datatable.defaultview.sort that was set with some value does not coping as is in…
Neeraj Kumar Gupta
  • 2,157
  • 7
  • 30
  • 58
1
vote
1 answer

How is the object created when using ISerializationSurrogate?

I use ISerializationSurrogate. In object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) obj will be the empty new object. the MSDN says: The SetObjectData method is called during…
BennoDual
  • 5,865
  • 15
  • 67
  • 153