protected Exception CreateInvalidCastException(Type type, object value, string id) { if (value == null) return new InvalidCastException(SR.Format(SR.XmlInvalidNullCast, type.FullName)); else if (id == null) return new InvalidCastException(SR.Format(SR.XmlInvalidCast, value.GetType().FullName, type.FullName)); else return new InvalidCastException(SR.Format(SR.XmlInvalidCastWithId, value.GetType().FullName, type.FullName, id)); }