I use this function to serialize in xml file a collection of object.
public void SerializeEnvironment()
{
if (xs == null) xs = new XmlSerializer(typeof(IList<Classes.Environment>));
using (StreamWriter wr = new StreamWriter(ConfigFilePath))
xs.Serialize(wr, Environments);
}
The program works perfectly on my dev machine. But when i make deployment on other computers, the program failed on the serialization method with this error :
System.InvalidCastException:
[A]System.Collections.Generic.List1[Product] cannot be cast to
[B]System.Collections.Generic.List
1[Product].
Type A originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Type B originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterList1.Write3_ArrayOfEnvironment(Object o)
I test many things to resolve but without success.
Thanks in advance for any suggestions or resolution :)
In addition, here my object class :
[Serializable]
public class Environment
{
public string name { get; set; }
public string value { get; set; }
public Environment(){}
public Environment(string Name, string Value)
{
name = Name;
value = Value;
}
}