Questions tagged [iserializable]

54 questions
3
votes
2 answers

Resolving Circular References for Objects Implementing ISerializable

I'm writing my own IFormatter implementation and I cannot think of a way to resolve circular references between two types that both implement ISerializable. Here's the usual pattern: [Serializable] class Foo : ISerializable { private Bar…
Chris
  • 91
  • 3
2
votes
1 answer

Sonarcube does not like my implementation of serializable exception class

SonarCube shows me error "Update this implementation of 'ISerializable' to conform to the recommended serialization pattern" for the following exception implementation: [Serializable] public class UnrecoverableException : Exception, ISerializable { …
YMC
  • 4,243
  • 7
  • 44
  • 66
2
votes
0 answers

How to implement GetObjectData in object with ISerializable field that itself has custom serialization?

What is the correct way to implement ISerializable interface for the class that has ISerializable field? Assume I have the following two classes, and I have to implement custom serialization for both of them. How should I implement the…
2
votes
2 answers

Passing recursive collection through WCF

I want to pass a fairly generic set of data through a WCF method. The data is basically just a hierarchical set of key/value pairs, but it's nested to an arbitrary level. I originally considered passing it though as a single string and doing XML…
Miral
  • 11,743
  • 2
  • 44
  • 89
2
votes
1 answer

Is there a shortcut to binary-serialize every property in an object?

If there is an object in which every public property must be serialized and properties are simple (just numbers or strings or objects already implementing ISerializable), is there an easy way to do it without having to create…
Arseni Mourzenko
  • 45,791
  • 28
  • 101
  • 185
2
votes
3 answers

How to implement ISerializable in F#

Let's say you start off with this stub: [] type Bounderizer = val mutable _boundRect : Rectangle new (boundRect : Rectangle) = { _boundRect = boundRect ; } new () = { _boundRect = Rectangle(0, 0, 1, 1); } new (info:SerializationInfo,…
plinth
  • 45,549
  • 9
  • 75
  • 118
2
votes
1 answer

How to use: 1. ISerializable with Serializer.Merge/Serialize & 2. ProtoInclude with RuntimeTypeModel.Default?

I translate my project to use protobuf-net instead of BinaryFormatter. It looks like there is a lack of documentation http://code.google.com/p/protobuf-net/w/list I also looked up some examples from…
1
vote
1 answer

C# Does Deserialization Constructor get called INSTEAD of the default constructor?

I am just becoming familiar with serialization of objects in C#. I am wondering if the deserialization constructor is called INSTEAD OF the default constructor or IN ADDITION TO. If it is IN ADDITION TO, what order are these called in? For…
Doug
  • 4,486
  • 9
  • 29
  • 39
1
vote
1 answer

ISerializable de-serialization performance

When implementing ISerializable you write code such as this to perform custom deserialization... (Note: this is a trivial example and does not warrant custom deserialization). protected ClientInformation(SerializationInfo info, StreamingContext…
Remotec
  • 8,966
  • 20
  • 93
  • 139
1
vote
1 answer

How to serialize instances of classes generated by DbMetal?

I noticed DbMetal generates classes that don't implement the ISerializable interface, nor are marked with DataContractAttribute. What is the easiest way of serializing such classes? Is there any DbMetal parameter that could help me?
Jader Dias
  • 81,082
  • 147
  • 410
  • 611
1
vote
0 answers

ISerializable and DataContract

Using WCF In Silverlight services, typically we want to use the DataContract and Datamember attributes to opt into what we want to have serialized. This is what we send to and from the client. For most things this has never been a problem. However,…
tam
  • 1,546
  • 2
  • 13
  • 25
1
vote
0 answers

How to fix an inner NullReferenceException when working with a serializable class using the ISerializable interface?

I'm working on a project which uses 5 different libraries as modules. My task is to save and load this information from one of these libraries using another. I've made the functionality to save, however the loading/deserializing of the data gives me…
1
vote
1 answer

How can I make a method to take only serializable objects?

Although there is an interface named ISerializable, it seems to purpose to customize details when a type is marked [Serializable] attribute. If I understood correctly, the [Serializable] attribute by itself does not touch anything on a type it is…
minhee
  • 5,129
  • 5
  • 38
  • 77
1
vote
0 answers

Binary serialization versioning issue

I have a class implementing ISerializable. Old binary data cannot be deserialized after adding new field to that class due to the following error: SerializationException: No element named 'x' could be found. Shouldn't serializer automatically…
Dave
  • 2,255
  • 1
  • 14
  • 31
1
vote
1 answer

C#: [NonSerialized] when implementing ISerializable

I dont' understand the use of the [NonSerialized] attribute when implementing ISerializable on a class. I attended the "programming in C#" (Microsoft 20-483) course and it's used in few examples, but not in details. Take this…
benichka
  • 877
  • 1
  • 12
  • 30