ASP.NET Web API and [Serializable] class

You just need this one-liner to get Json.NET to ignore the [Serializable] semantics again: ((DefaultContractResolver)config.Formatters.JsonFormatter.SerializerSettings.ContractResolver).IgnoreSerializableAttribute = true; A better solution for you might be to get rid of [Serializable] altogether, stop using BinaryFormatter, and use a different serializer instead to do whatever caching you want to do, like the Json.NET serializer for example.

using XmlArrayItem attribute without XmlArray on Serializable C# class

The following should serialize properly the way you want. The clue being [XmlElement(“credentials”)] on the list. I did this by taking your xml, generating a schema (xsd) from it in Visual Studio. Then running xsd.exe on the schema to generate a class. (And some small edits) public class CredentialsSection { public string Username { get; … Read more

Why should I always make my Exceptions [serializable]? (.NET)

Because your exceptions may need to be marshalled between different AppDomains and if they aren’t (properly) serializable you will lose precious debugging information. Unlike other classes, you won’t have control over whether your exception will be marshalled — it will. When I mean “you won’t have control” I mean that classes you create generally have … Read more

What does Serializable mean?

Serialization is persisting an object from memory to a sequence of bits, for instance for saving onto the disk. Deserialization is the opposite – reading data from the disk to hydrate/create an object. In the context of your question, it is an interface that if implemented in a class, this class can automatically be serialized … Read more

What does it mean: The serializable class does not declare a static final serialVersionUID field? [duplicate]

From the javadoc: The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the … Read more