谁能向我解释为什么从 Exception 继承的以下类不序列化私有字段?
从异常派生时我应该手动序列化对象吗?
[Serializable]
public class Test : Exception
{
private int _errNo = 0;
private string _msg = String.Empty;
public int ErrNo
{
get { return _errNo; }
}
public string Msg
{
get { return _msg; }
}
public Test(int err, string msg)
{
_errNo = err;
_msg = msg;
}
protected Test(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext kontekst)
: base(info, kontekst)
{
}
}