Can't use DataContractSerializer - assembly mismatch?

I am trying to use DataContractSerializerto save some data in IsolatedStorage, however I met some unexpected problems. After adding the serializer to the code, I get the following errors during the build:

Error 3 The type "System.Xml.XmlWriter" is defined in an assembly that is not mentioned. You must add a reference to the assembly "System.Xml", Version = 4.0.0.0, Culture = Neutral, PublicKeyToken = b77a5c561934e089. C: \ Users \ Dániel \ Documents \ Visual Studio 2012 \ Projects \ GameLibs \ SpaceshipConquest \ SpaceshipConquest \ SpaceshipConquest \ Model \ GameState.cs 47 13 SpaceshipConquest

Error 4 The type "System.Xml.XmlReader" is defined in an assembly that is not mentioned. You must add a reference to the assembly "System.Xml", Version = 4.0.0.0, Culture = Neutral, PublicKeyToken = b77a5c561934e089. C: \ Users \ Dániel \ Documents \ Visual Studio 2012 \ Projects \ GameLibs \ SpaceshipConquest \ SpaceshipConquest \ SpaceshipConquest \ Model \ GameState.cs 62 21 SpaceshipConquest

Since the assembly is System.Xmlalready mentioned, I tried changing the reference version in the project file, but this will result in a new error at runtime:

The file or assembly name is 'System.Runtime.Serialization, Version = 4.0.0.0, Culture = Neutral, PublicKeyToken = B77A5C561934E089', or one of its dependencies was not found.

Any idea how to solve this?

: 4.0.0.0, , , System.dll 4.0.0.0, .

2: .cs , .

+4
1

, slution

using System.Xml.Serialization;

.cs. , , XmlSerializer, , .

+2

Source: https://habr.com/ru/post/1502907/


All Articles