I'm developing some app on Windows Phone 8.1 Silverlight.
I have a problem with data contracts:
When I'm comming back to my app after for examlple invoke file picker, I'm getting unhandled exception:
"Error in line 1 position 229. Element 'http://ift.tt/1tk0a69' contains data of the 'http://ift.tt/1NZ9dzn' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Task' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."
My Task class:
[DataContract]
public class Task
{
[DataMember]
[SQLite.PrimaryKey, SQLite.AutoIncrement]
public int IdTask { get; set; }
[DataMember]
public int IdTaskType { get; set; }
[DataMember]
public int? IdIssue { get; set; }
[DataMember]
public int? IdTaskGroup { get; set; }
[DataMember]
public long? IdPlannedRoute { get; set; }
[DataMember]
public int IdOperatorRegistering { get; set; }
[DataMember]
public int? IdOperatorPerformer { get; set; }
[DataMember]
public int _idTaskStatus { get; set; } //private
[DataMember]
public Microsoft.Xna.Framework.Color _color { get; set; } //priv
[DataMember]
public int IdTaskStatus
{
get { return _idTaskStatus; }
set
{
_idTaskStatus = value;
switch ((TaskStatus)value)
{
case TaskStatus.NotStarted:
{
this._color = Microsoft.Xna.Framework.Color.LightGray;
break;
}
case TaskStatus.InProgress:
{
this._color = Microsoft.Xna.Framework.Color.Yellow;
break;
}
case TaskStatus.WaitingForAcceptance:
{
this._color = Microsoft.Xna.Framework.Color.Blue;
break;
}
case TaskStatus.FinishedSuccesfully:
{
this._color = Microsoft.Xna.Framework.Color.Green;
break;
}
case TaskStatus.FinishedWithError:
{
this._color = Microsoft.Xna.Framework.Color.Red;
break;
}
case TaskStatus.Planned:
{
this._color = Microsoft.Xna.Framework.Color.Brown;
break;
}
case TaskStatus.Canceled:
{
this._color = Microsoft.Xna.Framework.Color.LightPink;
break;
}
case TaskStatus.Suspended:
{
this._color = Microsoft.Xna.Framework.Color.LightCyan;
break;
}
}
}
}
[DataMember]
public DateTime CreationDate { get; set; }
[DataMember]
public bool? Accepted { get; set; }
[DataMember]
public int? IdOperatorAccepted { get; set; }
[DataMember]
public DateTime? AcceptanceDate { get; set; }
[DataMember]
public string Notes { get; set; }
[DataMember]
public DateTime? Deadline { get; set; }
[DataMember]
public long? IdLocation { get; set; }
[DataMember]
public long IdLocationCORE { get; set; }
[DataMember]
public int? IdActor { get; set; }
[DataMember]
public string TopicNumber { get; set; }
[DataMember]
public int Priority { get; set; }
[DataMember]
public long? OperationCode { get; set; }
[DataMember]
public int IdDistributor { get; set; }
[DataMember]
public int TaskFormType { get; set; }
[DataMember]
public DateTime? ArrangeDate { get; set; }
[DataMember]
public int? ArrangeDateStartHour { get; set; }
[DataMember]
public int? ArrangeDateEndHour { get; set; }
[DataMember]
public string ArrangeDateNote { get; set; }
[DataMember]
public string ArrangeDateMode { get; set; }
[DataMember]
public string _statusText { get; set; }
[DataMember]
public string Title
{
get
{
return string.Format("ID: {0} Status: {1}", this.IdTask, this._statusText);
}
set { Title = value; }
}
[DataMember]
public System.Windows.Visibility Visibility { get; set; }
[DataMember]
public string Status
{
get {
return string.Format("#FF{0}{1}{2}", this._color.R.ToString("X2"), this._color.G.ToString("X2"), this._color.B.ToString("X2"));
}
set { Status = value; }
}
[DataMember]
public Location _Location { get; set; }//priv
[DataMember]
public Location Location
{
get { return _Location; }
set
{
if (value == null)
{
this.IdLocation = null;
this._Location = null;
}
else
{
this.IdLocation = value.LocationID;
this._Location = value;
}
}
}
public Task()
{
}
public Task(int IdTask, int IdTaskType, int IdOperatorRegistering, int IdTaskStatus, DateTime CreationDate,
int Priority, int IdDistributor, int? IdIssue = null, int? IdTaskGroup = null, long? IdPlannedRoute = null,
int? IdOperatorPerformer = null, bool? Accepted = null, int? IdOperatorAccepted = null, DateTime? AcceptanceDate = null,
string Notes = null, DateTime? Deadline = null, long? IdLocation = null, int? IdActor = null,
string TopicNumber = null, long? OperationCode = null,
Location Location = null, int? TaskFormType = null)
{
this.IdTask = IdTask;
this.IdTaskType = IdTaskType;
this.IdOperatorRegistering = IdOperatorRegistering;
this.IdTaskStatus = IdTaskStatus;
this.CreationDate = CreationDate;
this.Priority = Priority;
this.IdDistributor = IdDistributor;
this.IdIssue = IdIssue;
this.IdTaskGroup = IdTaskGroup;
this.IdPlannedRoute = IdPlannedRoute;
this.IdOperatorPerformer = IdOperatorPerformer;
this.Accepted = Accepted;
this.IdOperatorAccepted = IdOperatorAccepted;
this.AcceptanceDate = AcceptanceDate;
this.Notes = Notes;
this.Deadline = Deadline;
if (Location != null)
this.Location = Location;
else
this.IdLocation = IdLocation;
this.IdActor = IdActor;
this.TopicNumber = TopicNumber;
this.OperationCode = OperationCode;
this.TaskFormType = TaskFormType.HasValue ? 0 : TaskFormType.Value;
}
}
In my app I'm using SQlite for Windows Phone package library.
Any idea how to fix this problem? :)
Aucun commentaire:
Enregistrer un commentaire