2017-04-18 07:52:04 +08:00
## NetDataContractSerializer fails to deserialize a ConcurrentDictionary serialized with a different .NET version
2017-04-06 04:52:19 +08:00
### Scope
Minor
### Version Introduced
4.5.1
### Source Analyzer Status
Planned
### Change Description
2017-04-21 02:19:05 +08:00
By design, the < xref:System.Runtime.Serialization.NetDataContractSerializer ? displayProperty = name >
can be used only if both the serializing and deserializing ends share the same
CLR types. Therefore, it is not guaranteed that an object serialized with one
version of the .NET Framework can be deserialized by a different version.
< xref:System.Collections.Concurrent.ConcurrentDictionary ` 2 ? displayProperty = name >
is a type that is known to not to deserialize correctly if serialized with the
.NET Framework 4.5 or earlier and deserialized with the .NET Framework 4.5.1 or
later.
2017-04-06 04:52:19 +08:00
- [ ] Quirked
- [ ] Build-time break
### Recommended Action
2017-04-21 02:19:05 +08:00
2017-04-06 04:52:19 +08:00
There are a number of possible work-arounds for this issue:
- Upgrade the serializing computer to use the .NET Framework 4.5.1, as well.
2017-04-21 02:19:05 +08:00
- Use < xref:System.Runtime.Serialization.DataContractSerializer ? displayProperty = name > instead of < xref:System.Runtime.Serialization.NetDataContractSerializer ? displayProperty = name > as this does not expect the exact same CLR types at both serializing and deserializing ends.
- Use < xref:System.Collections.Generic.Dictionary ` 2 ? displayProperty = name > instead of < xref:System.Collections.Concurrent.ConcurrentDictionary ` 2 ? displayProperty = name > since it does not exhibit this particular 4.5->4.5.1 break.
2017-04-06 04:52:19 +08:00
### Affected APIs
* `M:System.Runtime.Serialization.NetDataContractSerializer.Deserialize(System.IO.Stream)`
### Category
Serialization
[More information ](http://stackoverflow.com/questions/19585791/net-4-5-1-wcf-serialization-exception )
2017-04-18 07:52:04 +08:00
<!-- breaking change id: 110 -->