Open Anhaltiner0708 opened 8 years ago
It looks like you're getting multiple calls because you're subscribing for MemberDeserialized events, which (as of 5.0) includes a copy of the current value and therefore requires a call to the constructor. However, I don't know why it wouldn't have all the expected data. Can you show me an example of what you're deserializing so I can play with it?
Thanks
On Tue, May 17, 2016 at 3:24 AM, Anhaltiner0708 notifications@github.com wrote:
Hi Jeff,
during serialization, the constructor is called multiple times.
My class class contains a list and a count-property without a setter. In this case, the serializer use the special constructor, which contains the appropriate parameters. My Constructor throws an argument exception, if the count does not match to the given list.
The final constructor call is Ok. But the previous calls does not contains the fully list from stream. Because of the difference between the count and list, the constructor throws an argument exception. Can you turn off the unnecessary constructor calls before the final call?
Regards Dirk
Stack:
App.Subsystem.Conveyor.Messages.dll!App.Subsystem.Conveyor.Messages.States.MachineState.MachineState(ushort posDataCnt, System.Collections.ObjectModel.Collection posData) Zeile 87 C# [Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.GetValue(System.Func childValueSelector) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.Value.get() Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.CreateSerializationContext() Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.CreateSerializationContext() Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.CreateSerializationContext() Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.CreateSerializationContext() Unbekannt mscorlib.dll!System.Lazy.CreateValue() Unbekannt mscorlib.dll!System.Lazy.LazyInitValue() Unbekannt mscorlib.dll!System.Lazy.Value.get() Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BinarySerialization.BoundedStream stream, long? maxLength, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BinarySerialization.BoundedStream stream, long? maxLength, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.CollectionValueNode.DeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BinarySerialization.BoundedStream stream, long? maxLength, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BinarySerialization.BoundedStream stream, long? maxLength, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ContextValueNode.DeserializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BinarySerialization.BoundedStream stream, long? maxLength, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unbekannt BinarySerializer.dll!BinarySerialization.BinarySerializer.Deserialize(System.IO.Stream stream, System.Type type, object context) Unbekannt BinarySerializer.dll!BinarySerialization.BinarySerializer.Deserialize(System.IO.Stream stream, object context) Unbekannt Plat.System.BinarySerializerHelper.dll!Plat.System.BinarySerializerHelper.BinarySerializerHelper.BinaryDeserializeMessage(byte[] msgBin) Zeile 156 C# App.Subsystem.Conveyor.NUnit.dll!App.Subsystem.Conveyor.NUnit.Common.MsgBaseTests.DeserializeMessageBigEndian(App.Subsystem.Conveyor.Messages.States.MachineState expectedObj, byte[] source) Zeile 617 C# [Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
nunit.framework.dll!NUnit.Framework.Internal.Reflect.InvokeMethod(System.Reflection.MethodInfo method, object fixture, object[] args) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.MethodWrapper.Invoke(object fixture, object[] args) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Commands.TestMethodCommand.RunNonAsyncTestMethod(NUnit.Framework.Internal.TestExecutionContext context) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(NUnit.Framework.Internal.TestExecutionContext context) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(NUnit.Framework.Internal.TestExecutionContext context) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Commands.TestActionCommand.Execute(NUnit.Framework.Internal.TestExecutionContext context) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Commands.SetUpTearDownCommand.Execute(NUnit.Framework.Internal.TestExecutionContext context) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem work) Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.RunTest() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.WorkItem.Execute() Unbekannt nunit.framework.dll!NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher.RunnerThreadProc() Unbekannt mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) Unbekannt mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unbekannt mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unbekannt mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unbekannt mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() Unbekannt [Übergang von Systemeigen zu Verwaltet]
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jefffhaynes/BinarySerializer/issues/38
If you want to build a ship, don't drum up people together to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.
Antoine de Saint-Exupery
Hi Jeff,
you are right! The constructor is called only once, if I do not subsrcibe for the MemberDeserializing event or MemberDeserialized event. Otherwise, the constructor is called without all data.
Regards Dirk
example class
/// <summary>
/// the position data structure
/// </summary>
public class PositionData1
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="PositionData"/> class.
/// </summary>
public PositionData1()
: base()
{
}
#endregion
#region public properties
/// <summary>
/// Gets or sets the adress of position
/// </summary>
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt4)]
public uint Address { get; set; }
#endregion
}
/// <summary>
/// machine state message
/// </summary>
public class MachineState1
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="MachineState1"/> class.
/// </summary>
public MachineState1()
: this(0, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MachineState1"/> class.
/// </summary>
/// <param name="posDataCnt">
/// initial value for count of position data
/// </param>
/// <param name="posData">
/// initial list of position data
/// </param>
/// <remarks>
/// this constructor is used by the serializer. Because of there is no setter for the properties PosDataCnt and PosData
/// </remarks>
/// <exception cref="ArgumentException"></exception>
public MachineState1(ushort posDataCnt, Collection<PositionData1> posData)
: base()
{
if (posDataCnt != (posData?.Count ?? 0))
{
throw new ArgumentException("Position data count does not match with list of postion data", nameof(posDataCnt));
}
this.PosData = posData ?? new Collection<PositionData1>();
}
#endregion
#region public properties
/// <summary>
/// Gets or sets the position data count
/// </summary>
[FieldOrder(5)]
[SerializeAs(SerializedType = SerializedType.UInt2)]
public ushort PosDataCnt
{
get
{
return (this.PosData == null)
? (byte)0
: (this.PosData.Count > ushort.MaxValue) ? ushort.MaxValue : Convert.ToUInt16(this.PosData.Count);
}
}
/// <summary>
/// Gets or sets the data of all postions.
/// </summary>
[FieldOrder(6)]
[FieldCount("PosDataCnt")]
public Collection<PositionData1> PosData { get; private set; }
#endregion
}
testmethod
public void DeserializeMessage()
{
var serializer = new BinarySerializer() { Endianness = Endianness.Little };
serializer.MemberDeserializing += (sender, args) =>
{
MachineStateTests.Logger.DebugFormat("Deserializing {0}, stream offset {1}", args.MemberName, args.Offset);
};
serializer.MemberDeserialized += (sender, args) =>
{
MachineStateTests.Logger.DebugFormat("Deserialized {0}, ({1}), stream offset {2}", args.MemberName, args.Value ?? "null", args.Offset);
};
var inBytes = new byte[]
{
0x02, 0x00,0x78, 0xFF, 0x00, 0x00,0x30, 0x60, 0x03, 0x01
};
using (var stream = new MemoryStream(inBytes))
{
var actualObj = serializer.Deserialize<MachineState1>(stream);
Assert.AreEqual(null, actualObj, "Deserialization done with invalid Stream.");
}
}
Yeah, this is the result of the serializer basically trying to report the state of things "so far" where "so far" means that the collection count has been initialized but not the collection itself. I need to think about it a little more but I don't see any obvious fix if you want to do that check in your constructor.
That being said, playing around with it there is a sort of weird thing where you want to have the count field there for serialization but for deserialization with immutable types it's just kind of in the way. Let me think about how best to address that
Cheers
Hi Jeff,
I have the same problem. The constructor is called multiple time even if i don't subscribe the Member(De)serialized events. I try to use the custom serialize class as shown in u example in the readme.
I had to change it to the serializationContext.Value to get the right value serialize. Is there something wrong with my class or what do I have to change.
André
my class:
public class TimestampStruct : IBinarySerializable
{
public TimestampStruct()
{ }
/// <summary> Gets or sets the time of the date. </summary>
/// <value> The time of the date. </value>
[Ignore]
public DateTime Value { get; set; }
/// <summary> Deserializes to the object. </summary>
/// <param name="stream"> The stream. </param>
/// <param name="endianness"> The endianness. </param>
/// <param name="serializationContext"> Context for the serialization. </param>
public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
{
var data = new byte[8];
if (stream.Read(data, 0, data.Length) == -1)
{
throw new InvalidOperationException("Could not read stream");
}
var year = data[0].AsSByte() + 2000;
var month = data[1];
var day = data[2];
var hour = data[3];
var minute = data[4];
var second = data[5];
var millisecond = BitConverter.ToUInt16(data, 6);
if (month == 0 || day == 0)
{
this.Value = DateTime.MinValue;
}
else
{
this.Value = new DateTime(year, month, day, hour, minute, second, millisecond, DateTimeKind.Utc);
}
}
/// <summary> Serializes the object to the stream. </summary>
/// <param name="stream"> The stream. </param>
/// <param name="endianness"> The endianness. </param>
/// <param name="serializationContext"> Context for the serialization. </param>
public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
{
var value = (serializationContext.Value as TimestampStruct).Value;
if (value == DateTime.MinValue)
{
stream.Write(new byte[8], 0, 8);
return;
}
stream.WriteByte((value.Year - 2000).ToSByte().AsByte());
stream.WriteByte(value.Month.ToByte());
stream.WriteByte(value.Day.ToByte());
stream.WriteByte(value.Hour.ToByte());
stream.WriteByte(value.Minute.ToByte());
stream.WriteByte(value.Second.ToByte());
stream.Write(value.Millisecond.ToUInt16().GetBytes(), 0, sizeof(ushort));
}
public override string ToString()
{
return this.Value.ToString();
}
}
call stack
Zookeeper.dll!Zookeeper.InternalMessages.TimestampStruct.TimestampStruct() Line 16 C# [Lightweight Function] BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.GetValue(System.Func<BinarySerialization.Graph.ValueGraph.ValueNode,object> childValueSelector) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.BoundValue.get() Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.CustomValueNode.ObjectSerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.SerializeInternal(BinarySerialization.BoundedStream stream, System.Func<long?> maxLengthDelegate, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle, bool align) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectSerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.SerializeInternal(BinarySerialization.BoundedStream stream, System.Func<long?> maxLengthDelegate, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle, bool align) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectSerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.SerializeInternal(BinarySerialization.BoundedStream stream, System.Func<long?> maxLengthDelegate, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle, bool align) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.RootValueNode.SerializeOverride(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.SerializeInternal(BinarySerialization.BoundedStream stream, System.Func<long?> maxLengthDelegate, BinarySerialization.EventShuttle eventShuttle) Unknown BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(BinarySerialization.BoundedStream stream, BinarySerialization.EventShuttle eventShuttle, bool align) Unknown BinarySerializer.dll!BinarySerialization.BinarySerializer.Serialize(System.IO.Stream stream, object value, object context) Unknown
I'll have to refresh my memory. I should have time this weekend.
I'm not sure what the problem is that you're having. Can you give me some more context? There doesn't appear to be an actual exception in the stack you sent and I don't know what you mean when you say the constructor is being called multiple times. The code you posted looks correct to me and runs when I try it.
If I break in the 'Serialize' method the Property of the class is not set. I had to use the object form the binary context instead. So the Object where the Serialize called from is not he same object.
Ah, I see the problem. It doesn't know how to serialize DateTime so it isn't including it in the generated graph, even though it doesn't need to serialize it. Let me work on it...
Oh Create, Thanks you Do you have idea how implement kind of Bitfields.
Your issue was fixed in 6.0.2 (just pushed). However, it is not related to the original issue posted here. Please open new issues if you have subsequent questions. Thanks.
Hi Jeff,
during serialization, the constructor is called multiple times.
My class class contains a list and a count-property without a setter. In this case, the serializer use the special constructor, which contains the appropriate parameters. My Constructor throws an argument exception, if the count does not match to the given list.
The final constructor call is Ok. But the previous calls does not contains the fully list from stream. Because of the difference between the count and list, the constructor throws an argument exception. Can you turn off the unnecessary constructor calls before the final call?
Regards Dirk
Stack: