I'm trying to use the DataContractSerializer
to save some data in the IsolatedStorage
, however I've met some unexpected problems. After adding the serializer to the code, I get the following errors during building:
Error 3 The type 'System.Xml.XmlWriter' is defined in an assembly that is not referenced. You must add a reference to 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 referenced. You must add a reference to 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 System.Xml
assembly is already referenced I've tried to change the reference version in the project file - but this lead to a new error during runtime:
File or assembly name '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?
Edit: I've tried setting every assembly version to 4.0.0.0, but it seems that they would also need the System.dll's 4.0.0.0 version, which I can not set.
Edit 2: I've also tried copying over the .cs files to a new project, but that didn't solve the problem either.
The problem was solved, after much trial the slution was adding
using System.Xml.Serialization;
to the header of the .cs file. It seems that even though the assembly was imported, it couldn't use the XmlSerializer without specifying that I'm using it's assembly.