I use JSON.Net to serialize the DTO and I get the following exception on the physical device. This works on all the other devices we tested on, but does not work on the Samsung Galaxy Tab 3lite SM-T110 version 4.2.2.
I had this question , but when I upgraded to Xamarin 3.0, it became as follows:
06-03 21:17:41.687 E/mono-rt (22071): [ERROR] FATAL UNHANDLED EXCEPTION: System.TimeZoneNotFoundException: Exception of type 'System.TimeZoneNotFoundException' was thrown. 06-03 21:17:41.687 E/mono-rt (22071): at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0 06-03 21:17:41.687 E/mono-rt (22071): at Newtonsoft.Json.Utilities.DateTimeUtils.GetUtcOffset (DateTime d) [0x00000] in <filename unknown>:0 06-03 21:17:41.687 E/mono-rt (22071): at Newtonsoft.Json.Utilities.DateTimeUtils.WriteDateTimeString (System.Char[] chars, Int32 start, DateTime value, Nullable`1 offset, DateTimeKind kind, DateFormatHandling format) [0x00000] in <filename unknown>:0 06-03 21:17:41.687 E/mono-rt (22071): at Newtonsoft.Json.JsonTextWriter.WriteValue (DateTime value) [0x00000] in <filename unknown>:0 06-03 21:17:41.687 E/mono-rt (22071): at Newtonsoft.Json.JsonWriter.WriteValue (Newtonsoft.Json.JsonWriter writer, PrimitiveTypeCode typeCode, System.Object value) [0x00000] in <filename unknown>:0 06-03 21:17:41.687 E/mono-rt (22071): at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializePrimitive (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonPrimitiveContract contract, Newtonsoft.Json.Serialization. 06-03 21:17:41.695 I/mono-stdout(22071): Executing Command: UpdateRegistration The program 'Mono' has exited with code 0 (0x0).
EDIT This is the DTO I'm trying to serialize. You can see when the called constructor is called, it sets it to DateTime.Now . Should this just suggest a local time zone?
public class RecordTargetFrequency : BaseCommand, ICommand { public Guid TargetId { get; private set; } public Guid? LocationId { get; private set; } public Guid TherapistId { get; private set; } public bool? Increase { get; private set; } public DateTime TimeStamp { get; private set; } public RecordTargetFrequency(Guid targetId, Guid? locationId, Guid therapistId, bool? increase) { TimeStamp = DateTime.Now; TargetId = targetId; LocationId = locationId; TherapistId = therapistId; Increase = increase; } public void Validate() { ValidateGuid(TargetId); ValidateGuid(TherapistId); } }
Then I serialize it using this line:
JsonConvert.SerializeObject(executedCommand);
source share