Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

XmlSerializer and Rectangles/Vectors/Colors

$
0
0

@StaticRich wrote:

I have a List<object> which contains various different data types including int, float, bool, Rectangle, Color, Vector2, and Vector3. Previously, in XNA 4.0, I was able to use an XmlSerializer to export all of these data types to (and import them from) an XML document. Now, in MonoGame 3.0, it no longer works with Rectangle, Color, Vector2, or Vector3. This is the error that I get for all of them:

System.InvalidOperationException: 'There was an error generating the XML document.'
Inner Exception
InvalidOperationExcetion: The type Microsoft.Xna.Framework.Rectangle was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

I have tried putting [XmlInclude(typeof(Rectangle))] right above my class declaration, but this does nothing. Am I doing it wrong? Perhaps this has something to do with the fact that my List is of the generic object type?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles