Hi All,
I have a problem that I'm working in nHibernate project that have the following object:
[Serializable]
public class Prototype
{
public virtual long Id { get; private set; }
public virtual string Name { get; set; }
public virtual IList<AttributeGroup> AttributeGroups { get; private set; }
}
and I have created a method to deserialize an XML file and put it into object of type Prototype as following :
public static T Deserialize(string fileName)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
XmlTextReader xmlTextReader = new XmlTextReader(fileName);
Object c = xmlSerializer.Deserialize(xmlTextReader);
return (T)c;
}
The problem now that I have the following exception
Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericBag`1[BCatalog.Entities.AttributeGroup]' to type 'System.Collections.Generic.List`1[BCatalog.Entities.AttributeGroup]'.
I can't change the type of the IList because of the nHibernate and I want to deserialize the object
what should I do to solve this problem ?
please answer me as soon as you can
Thanks in Advance