Sandip D
Sandip D

Reputation: 121

Why Soap Serializer does not support serializing Generic Types?

I have tried to serialize Dictionary<string, string> using SoapFormatter, but it throws an exception

Soap Serializer does not support serializing Generic Types : System.Collections.Generic.Dictionary`2[System.String,System.String].

Serialization of Dictionary<string, string> works with BinaryFormatter.

Anyone have idea about why SoapFormatter does not support serializing Generic Types?

Upvotes: 2

Views: 1958

Answers (1)

Novin.Kh
Novin.Kh

Reputation: 129

The SoapFormatter class can only serialize objects that could have been created with .NET 1.1.

As generic types were not introduced until .NET 2.0, they cannot therefore be serialized.

If you're trying to serialize a List, then you could use an ArrayList instead or, if you're trying to serialize a generic Dictionary then you could use a Hashset.

Otherwise, I'd use the BinaryFormatter instead.

Upvotes: 4

Related Questions