我有一个复杂的对象类用户Info,其中包含另一个类对象的列表。
复杂的对象:
[Serializable]
public class MESServerCluster
{
[XmlArray("MesServers")]
public List<MESServer> MesServers { get; set; }
public MESServerCluster() {}
}
实体对象:
[Serializable]
public class MESServer {
[System.Xml.Serialization.XmlIgnore()]
public string NBLVIP { get; set; }
public string ServerDomain { set; get; }
public string ServerIPAddress { set; get; }
public string ServerUsername { get; set; }
public string ServerPassword { set; get; }
[System.Xml.Serialization.XmlIgnore()]
private Win32_Process wmi;
public Win32_Process WMI
{
get
{
return wmi;
}
private set
{
wmi = value;
}
}
public MESServer() { }
public MESServer(string serverdomain, string serveripaddress, string serverusername, string serverpassword)
{
this.ServerDomain = serverdomain;
this.ServerIPAddress = serveripaddress;
this.ServerUsername = serverusername;
this.ServerPassword = serverpassword;
}
public void InitWMI()
{
try
{
this.WMI = new Win32_Process(this.ServerDomain, this.ServerIPAddress, this.ServerUsername, this.ServerPassword);
}
catch (Exception ex){
throw ex;
}
}
通过代码引发异常: XmlSerializer xmldes =新的XmlSerializer(typeof(MESServerCluster));
答案 0 :(得分:0)
如果您将[System.Xml.Serialization.XmlIgnore()]
属性添加到Win32_Process
字段,也将此属性也添加到您的Win32_Process
属性。顺便说一句,您的异常消息应该很重要,可以在此处发布。