Adding a new constructor
public Error(SerializationInfo info, StreamingContext context){}
solved my problem.
Here complete code:
[Serializable]
public class Error : Exception
{
public string ErrorMessage { get; set; }
public Error(SerializationInfo info, StreamingContext context)
{
if (info != null)
this.ErrorMessage = info.GetString("ErrorMessage");
}
public override void GetObjectData(SerializationInfo info,StreamingContext context)
{
base.GetObjectData(info, context);
if (info != null)
info.AddValue("ErrorMessage", this.ErrorMessage);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…