1
似乎sgen.exe不能生成泛型類型XmlSerializer,對吧?
我genereic類型:Sgen.exe中的Bug
[Serializable]
[XmlRoot(ElementName = "Masterx")]
public class Masterx<T> where T : class, new()
{....}
串行代碼:
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;
}
運行sgen.exe後,通過使用 「反射鏡」 檢查生成的彙編,我發現生成的程序集不包含MasterxXmlSerializer類,爲什麼?
有人有同樣的經歷嗎?如何解決它?
似乎沒有人知道我的問題:( – Rock 2009-08-25 10:16:41