我有这个异常类:
[Serializable]
public class LoginException : Exception
{
public LoginError LoginError { get; private set; }
public LoginException(LoginError loginError)
{
this.LoginError = loginError;
}
public LoginException(SerializationInfo info, StreamingContext context)
{
if (info != null)
{
this.LoginError = (LoginError)info.GetValue("LoginError", typeof(LoginError));
}
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
if (info != null)
{
info.AddValue("LoginError", this.LoginError);
}
}
}
当我从WebApi操作返回此异常时,我得到以下异常:
System.Runtime.Serialization.SerializationException: Member 'LoginError' was not found. at System.Runtime.Serialization.SerializationInfo.GetElement(String name, Type& foundType) at System.Runtime.Serialization.SerializationInfo.GetValue(String name, Type type)
我在这里缺少什么?