problem with Xml Serialization

i make a game guiding with Tutorial(C# Monogame RPG Made Easy Tutorial 3 - Xml Serialization)
and i have some error
`using System;
using System.Xml.Serialization;
using System.IO;

namespace CatRocks
{
    public class xmlManager<T>
    {
        public Type Type ; 

        public T Load(string path) {
            T instance;
            using (TextReader reader = new StreamReader(path))
            {

                XmlSerializer xml = new XmlSerializer(Type);
                instance = (T)xml.Deserialize(reader);
            }
            return instance;
        }
        public void Save(string path,object obj) {
            using (TextWriter writer = new StreamWriter(path))
            {
                XmlSerializer xml = new XmlSerializer(Type);
                xml.Serialize(writer, obj);
            }
        }
    }
}

and i have this error Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from ‘string’ to ‘System.IO.Stream’ CatRocks C:\Users\Pedro\documents\visual studio 2015\Projects\CatRocks\CatRocks\xmlManager.cs 13 Active
Error CS1503 Argument 1: cannot convert from ‘string’ to ‘System.IO.Stream’ CatRocks C:\Users\Pedro\documents\visual studio 2015\Projects\CatRocks\CatRocks\xmlManager.cs 22 Active
but in Tutorial don´t existe
i using the monogame 3.5
can someone help-me

Haven’t had time to find exactly the error you’ve made, but converted the class to static, removed the unnecessary Type-parameter (can be inferred) and tested it… works now; at least on my system…
here it is:

public static class XmlManager
{
    public static T Load<T>(string path)
    {
        using (TextReader reader = new StreamReader(path))
        {
            XmlSerializer xml = new XmlSerializer(typeof(T));
            return (T)xml.Deserialize(reader);
        }
    }

    public static void Save<T>(string path, T obj)
    {
        using (TextWriter writer = new StreamWriter(path))
        {
            XmlSerializer xml = new XmlSerializer(typeof(T));
            xml.Serialize(writer, obj);
        }
    }
}

Here’s how you’d use it:

[Test]
public void Ttt()
{
    XmlManager.Save("test.xml", "This is a test.");
    string s = XmlManager.Load<string>("test.xml");
    Console.Out.WriteLine(s);
}

the problem i think is becouse i using monogame project universal windows

Have you tried my code?
Does it fail as well?
At what line, what error and what was the command that failed (save or load)?
thx, cu.

yes and i have the same error
but when i create a new project using monogame desktop project the code work
this is the error i have in the project universal windows
public T Load(string path) {
T instance;
using (TextReader reader = new StreamReader(path)) //cannot convert from ‘string’ to ‘System.IO.Stream’
{

            XmlSerializer xml = new XmlSerializer(Type);
            instance = (T)xml.Deserialize(reader);
        }
        return instance;
    }
    public void Save(string path,object obj) {
        using (TextWriter writer = new StreamWriter(path)) //cannot convert from 'string' to 'System.IO.Stream' 
        {
            XmlSerializer xml = new XmlSerializer(Type);
            xml.Serialize(writer, obj);
        }
    }

Hmmm. Indeed… You’ve diagnosed it right.
Here’s a more detailed answer from StackOverflow describing your problem, and a solution.

Seems that you’re not allowed to just read/write to files out of a Windows Universal App.
You’d have to use specially protected storage like in the answer above.

Here’s a more detailed answer with examples for reading and writing from/to such a storage file.
You’d have to serialize the objects to a XML-string and then save that to the storage.

Here’s my code for string - serialization:

public static string XmlSerialization(object inputObject, Encoding encodingType)
{
	string xmlResult;
	using (Stream stream = new MemoryStream())
	{
		XmlSerializer s = new XmlSerializer(inputObject.GetType());
		s.Serialize(stream, inputObject);
		stream.Position = 0;
		byte[] b = new byte[stream.Length];
		stream.Read(b, 0, (int) stream.Length);
		xmlResult = encodingType.GetString(b, 0, b.Length);
	}
	return xmlResult;
}

aaaaand here…

public static T XmlDeserialization<T>(string inputString, Encoding encodingType)
{
	Object obj;
	using (new StringReader(inputString))
	{
		byte[] b;
		b = encodingType.GetBytes(inputString);
		Stream stream = new MemoryStream(b);
		XmlSerializer s = new XmlSerializer(typeof (T));
		obj = s.Deserialize(stream);
	}
	return (T) obj;
}

EncodingType would be Encoding.UTF8 most of the time.

Hope that helps,
Psilo

thanks for the help
i put the project universal windows in stand by for now
i now make the game for desktop

Np. Anytime.
Post when you need help.
Cu