It seems that sgen.exe could not generate generic type XmlSerializer, right?
My genereic type:
[Serializable]
[XmlRoot(ElementName = "Masterx")]
public class Masterx<T> where T : class, new()
{....}
Serializer code:
protected virtual List<T> ParseXMLToObject<T>(string resultXML) where T : class, new()
{
//return ParseXMLToObject<T>(resultXML, "Masterx");
XmlSerializer xs = new XmlSerializer(typeof(Masterx<T>));
System.IO.StringReader sr = new System.IO.StringReader(resultXML);
XmlReader xr = XmlReader.Create(sr);
Masterx<T> masterx = null;
if (!string.IsNullOrEmpty(resultXML))
{
if (xs.CanDeserialize(xr))
{
//Parse the xml to object
masterx = xs.Deserialize(xr) as Masterx<T>;
}
}
List<T> rtnObjList = new List<T>();
if (masterx != null)
{
rtnObjList = masterx.MasterxRowList;
}
return rtnObjList;
}
After run sgen.exe and check generated assembly by using "Reflector", I found that generated assembly didn't contain MasterxXmlSerializer class, why?
Does someone have same experience? How to fix it?