jefffhaynes / binaryserializer Goto Github PK
View Code? Open in Web Editor NEWA declarative serialization framework for controlling formatting of data at the byte and bit level using field bindings, converters, and code.
License: MIT License
A declarative serialization framework for controlling formatting of data at the byte and bit level using field bindings, converters, and code.
License: MIT License
What is licence for using binaryserializer and where can be found documentation?
I'm baffled.
I'll update test case shortly.
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Error serializing type 'Pandacorn.Core.XXXX.ChunkContainer'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.BinarySerializer.Serialize(Stream stream, Object value, Object context) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\BinarySerializer.cs:line 130
at xxx.xxxx.Program.Main(String[] args) in C:\s\xxx\xxxx\xxxx\Program.cs:line 163
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
HResult=-2146233079
Message=Error serializing type 'xxx.Core.XXXX.ChunkContainer'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ContextValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ContextValueNode.cs:line 85
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'ChunkLength'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'Chunk'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ValueNode.MeasureOverride() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 216
at BinarySerialization.Graph.ValueGraph.ValueNode.<Bind>b__19_0() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 59
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 45
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'Chunks'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing type 'xxx.Core.XXXX.ChunkContainer'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.CollectionValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\CollectionValueNode.cs:line 27
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'ChunkLength'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'Chunk'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ValueNode.MeasureOverride() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 216
at BinarySerialization.Graph.ValueGraph.ValueNode.<Bind>b__19_0() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 59
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 45
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233079
Message=Error serializing member 'ZoneCount'. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
HResult=-2146233088
Message=Multiple bindings to a single source must have equivalent target values.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 52
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
InnerException:
This code throws OutOfMemoryException. I use version 2.6.0 from nuget package.
public class IntArray64K
{
[FieldLength(65536*sizeof(int))]
public int[] Arr { get; set; }
}
class MainClass
{
public static void Main (string[] args)
{
BinarySerializer ser = new BinarySerializer ();
byte[] data = new byte[65536 * sizeof(int)];
IntArray64K des0=ser.Deserialize<IntArray64K>(data);
using (MemoryStream ms = new MemoryStream (data)) {
IntArray64K des=ser.Deserialize<IntArray64K>(ms);
}
}
}
I'm coming across an issue again with nested subtypes. This time it occurs on serialization. What's baffling me is that It binds fine by itself, but when nested it doesn't work. It also doesn't work nested when I manually implement IBinarySerializable
Test Name: DeserializeOneZoneOneSampleThenInsertAuthorChunk
Test FullName: Pandacorn.Core.XXXX.Tests.XXXXBasicUnitTests.DeserializeOneZoneOneSampleThenInsertAuthorChunk
Test Source: C:\X\XXXX\XXXXXX\Pandacorn.Core.Tests\XXXX\ChunkyTests.cs : line 38
Test Outcome: Failed
Test Duration: 0:00:00.2779704
Result StackTrace:
at BinarySerialization.Graph.Binding.GetBoundValue(ValueNode target) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\Binding.cs:line 85
at BinarySerialization.Graph.ValueGraph.ValueNode.b__21_0(ConditionalBinding binding) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 106
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func
2 predicate)
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 105
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ValueNode.MeasureOverride() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 216
at BinarySerialization.Graph.ValueGraph.ValueNode.b__19_0() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 59
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 45
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.CollectionValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\CollectionValueNode.cs:line 27
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ValueNode.MeasureOverride() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 216
at BinarySerialization.Graph.ValueGraph.ValueNode.b__19_0() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 59
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 45
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.CollectionValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\CollectionValueNode.cs:line 27
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ValueNode.MeasureOverride() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 216
at BinarySerialization.Graph.ValueGraph.ValueNode.b__19_0() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 59
at BinarySerialization.Graph.ValueGraph.ValueValueNode.get_BoundValue() in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 45
at BinarySerialization.Graph.ValueGraph.ValueValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueValueNode.cs:line 64
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ObjectValueNode.cs:line 112
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.Graph.ValueGraph.ContextValueNode.SerializeOverride(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ContextValueNode.cs:line 85
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 119
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Serialize(StreamLimiter stream, EventShuttle eventShuttle) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\Graph\ValueGraph\ValueNode.cs:line 132
at BinarySerialization.BinarySerializer.Serialize(Stream stream, Object value, Object context) in C:\s\3rd\social\github\BinarySerializer\BinarySerializer\BinarySerializer.cs:line 130
at Pandacorn.Core.XXXX.Tests.XXXXBasicUnitTests.DeserializeOneZoneOneSampleThenInsertAuthorChunk() in C:\s\Pandacorn\XXXX\Pandacorn.Core.Tests\XXXX\ChunkyTests.cs:line 62
Result Message:
Test method Pandacorn.Core.XXXX.Tests.XXXXBasicUnitTests.DeserializeOneZoneOneSampleThenInsertAuthorChunk threw exception:
System.InvalidOperationException: Error serializing type 'Pandacorn.Core.NNXT.ChunkContainer'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing type 'Pandacorn.Core.XXXX.ChunkContainer'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'ChunkLength'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'Chunk'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'Chunks'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing type 'Pandacorn.Core.XXXX.ChunkContainer'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'ChunkLength'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'Chunk'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'CATS'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing type 'Pandacorn.Core.XXXX.ChunkContainer'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'ChunkLength'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'Chunk'. See inner exception for detail. ---> System.InvalidOperationException: Error serializing member 'PhysicalSampleName'. See inner exception for detail. ---> System.InvalidOperationException: Not a bindable source.
Hi, me again.
I am having issues with the IgnoreAttribute in certain cases. I have used it elsewhere, and it works
However, in one of my classes, I get at exception when deserializing.
System.InvalidOperationException: 'Module' does not have a FieldOrder attribute. All serializable fields or properties in a class with more than one member must specify a FieldOrder attribute.
If I comment out these fields, the deserialization works perfectly. Nothing in the object being deserialized is called "Module", so I assume that's something in the serializer?
Here is the rest of the stack trace:
at BinarySerialization.Graph.TypeGraph.ObjectTypeNode.GenerateChildrenImpl(Type parentType)
at BinarySerialization.Graph.TypeGraph.ObjectTypeNode.Construct()
at BinarySerialization.Graph.TypeGraph.ObjectTypeNode.GetSubType(Type type)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
at BinarySerialization.Graph.ValueGraph.CustomValueNode.ObjectDeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.CollectionValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.CollectionValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ContextValueNode.DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
--- End of inner exception stack trace ---
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(StreamLimiter stream, EventShuttle eventShuttle)
at BinarySerialization.BinarySerializer.Deserialize[T](Stream stream, Object context)
at BinarySerialization.BinarySerializer.Deserialize[T](Byte[] data, Object context)
Hi,
I'm new to BinarySerializer, but I would like to use it for my project. I have a usage scenario were I have the following format:
public class MessageBase{
[FieldOrder(0)]
public MessageHeader Header { get; set; }
[FieldOrder(1)]
public RemoteOperationHeader RemoteOpHeader { get; set; }
[FieldOrder(2)]
[Subtype("RemoteOpHeader.OpType", RemoteOpTypes.Invoke, typeof(RemoteInvokeOp))]
[Subtype("RemoteOpHeader.OpType", RemoteOpTypes.Command, typeof(RemoteInvokeComm))]
[Subtype("RemoteOpHeader.OpType", RemoteOpTypes.Result, typeof(RemoteInvokeRes))]
public RemoteOperationBase RemoteOperation { get; set; }
}
public class MessageHeader
{
[FieldOrder(0)]
public MessageType MessageType {get;set;}
[FieldOrder(1)]
public int MessageLength {get;set;} // Should be the length of the remainder of the message, i.e. the number of bytes that will follow.
}
public class RemoteOperationHeader
{
[FieldOrder(0)]
public RemoteOpTypes OpType {get;set;}
[FieldOrder(1)]
public int Length {get;set;} // Should be the length of the remainder of the message, i.e. the number of bytes that will follow.
}
public class Message:MessageBase{
// Should inherit the members of the base class and then add the next element to the message
[FieldOrder(0)]
public RemoteInvokeAction Action{get;set;}
}
Is such a scenario supported? And if yes, how can it be achieved?
Kind regards.
I'm not that familiar with git and github, so I was unsure how to create a pull request.
I found that it was needed to call a non-generic Deserialize() in my code. This could be solved by adding this to BinarySerializer.cs:
public object Deserialize(Stream stream, Type type, object context = null)
{
RootTypeNode graph = GetGraph(type);
var serializer = (ContextValueNode)graph.CreateSerializer(null);
serializer.EndiannessCallback = () => Endianness;
serializer.EncodingCallback = () => Encoding;
serializer.Context = context;
serializer.Deserialize(new StreamLimiter(stream), _eventShuttle);
return serializer.Value;
}
and change the existing methods to this:
public T Deserialize<T>(Stream stream, object context = null)
{
return (T) Deserialize(stream, typeof(T), context);
}
public T Deserialize<T>(byte[] data, object context = null)
{
return (T)Deserialize(new MemoryStream(data), typeof (T), context);
}
Hi Jeff,
I like to create an class, that contains the properties of a S7-String.
Serialization should return a stream of length Maxlength + 2 (bytes of max and current length).I would not use constants and bind the MaxLength property to the FieldLengthAttribute of the property Value. However, this leads to the result that the length of the stream depends on the property value and not on the property MaxLength.
Is there a way to define it without using the interface IBinarySerializable?
Best regards
Dirk
In the event that the stream is too short to fully serialize the object, an object is returned. The missing properties have values that have been assigned by the constructor.
In this case I expect any exception or the result is null.
Is there a way to verify that all properties have been read from Stream?
example class
public class LoadCarrierData
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="LoadCarrierData"/> class.
/// </summary>
public LoadCarrierData()
{
}
#endregion
#region public properties
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt4)]
public uint Prop1 { get; set; }
[FieldOrder(1)]
[SerializeAs(SerializedType = SerializedType.UInt1)]
public byte Prop2 { get; set; }
[FieldOrder(2)]
[SerializeAs(SerializedType = SerializedType.UInt1)]
public byte Prop3 { get; set; }
[FieldOrder(3)]
[SerializeAs(SerializedType = SerializedType.UInt4)]
public uint Prop4 { get; set; }
#endregion
}
test method
public void DeserializeInvalidMessageLittleEndian()
{
var serializer = new BinarySerializer() { Endianness = Endianness.Little };
var inBytes = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x40, 0x34 };
using (var stream = new MemoryStream(inBytes))
{
try
{
var actualObj = serializer.Deserialize<LoadCarrierData>(stream);
Assert.AreEqual(null, actualObj, "Deserialization done with invalid Stream.");
}
catch (InvalidOperationException ex)
{
//Expected System.IO.EndOfStreamException or System.InvalidOperationException
this.TestContext.WriteLine(ex.ToString());
}
}
}
From the serialization of the following object no bytes are written to the stream. What is wrong?
Object that should serialized
new LoadCarrierData(LoadCarrierType.Unknown, null);
I expect that two bytes (0x00, 0x00) are written to the stream!
public enum LoadCarrierType
{
/// <summary>
/// unknown
/// </summary>
Unknown = 0,
/// <summary>
/// bin 1
/// </summary>
Bin1 = 1,
/// <summary>
/// bin 2
/// </summary>
Bin2 = 2,
/// <summary>
/// palette
/// </summary>
Palette = 3,
/// <summary>
/// pipe
/// </summary>
Pipe = 4
}
public class LoadCarrierData
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="LoadCarrierData"/> class.
/// </summary>
public LoadCarrierData()
: this(LoadCarrierType.Unknown, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LoadCarrierData"/> class.
/// </summary>
/// <param name="carrierType">
/// The carrier Type.
/// </param>
/// <param name="data">
/// The data.
/// </param>
public LoadCarrierData(LoadCarrierType carrierType, BaseCarrierData data)
: base()
{
this.CarrierType = carrierType;
this.Data = data;
}
#endregion
#region public properties
/// <summary>
/// Gets or sets type of the load carrier
/// </summary>
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt2)]
public LoadCarrierType CarrierType { get; private set; }
/// <summary>
/// Gets or Sets the data
/// </summary>
[FieldOrder(1)]
[Subtype("CarrierType", LoadCarrierType.Unknown, typeof(BaseCarrierData))]
[Subtype("CarrierType", LoadCarrierType.Bin1, typeof(Bin1Data))]
[Subtype("CarrierType", LoadCarrierType.Bin2, typeof(Bin2Data))]
[Subtype("CarrierType", LoadCarrierType.Palette, typeof(PalData))]
[Subtype("CarrierType", LoadCarrierType.Pipe, typeof(PipeData))]
public BaseCarrierData Data { get; private set; }
#endregion
}
This could be useful in cases where there are multiple source fields that must be in agreement and must be updated during serialization. Case in point:
public class Block
{
[FieldOrder(0)]
public int Type { get; set; }
[FieldOrder(1)]
public int Length { get; set; }
[FieldOrder(2)]
[FieldLength("Length", ConverterType = typeof(SummingValueConverter), ConverterParameter = -12)]
[FieldLength("Length2", ConverterType = typeof(SummingValueConverter), ConverterParameter = -12)]
//[Subtype("Type", )]
public BlockBody Body { get; set; }
[FieldOrder(3)]
public int Length2 { get; set; }
}
It would be nice if path syntax supported indexers for collection binding
To interface with some legacy hardware a couple custom (de)serializers are needed for special data types that have variable but predefined lengths (i.e. length not defined in the data but by protocol specs). I have a working IBinarySerializable class but need to know how many bytes there are to generate or parse for a specific instance of the class. It appears that LimitedStream has the information I want in MaxLength, but as it is an internal class to BinarySerializer, I can't access it.
Is there a way, in an IBinarySerializable based class, to figure out how many bytes can be read or written (without wasting time probing, causing exceptions and catching them)? Thanks!
When trying to deserialize byte array object with FieldCount attribute , an exception occures: System.InvalidOperationException : No length specified on byte array.
The object
public class ByteArray64K
{
[FieldCount(65536)]
public byte[] Arr { get; set; }
}
Having a hard time finalizing my implementation for some knarly EA-IFF 85 form chunks.
No matter how I strucuture or wire it up, I always end up having to implement IbinarySerializer. The stream position refuses to increase when I try to add padding via converts or props.
there are 0 or more REFE chunks and the AUTH chunk is optional.
here's one (of about 10) different ways I've tried implementing REFS:
'''
///
/// There is a REFE chunk for every reference to XXX
/// you can have 0 or more REFE chunks. Currently we work with
/// two versions of this chunk: the version wriXXXXXXXXX
/// </summary>
public class RefeChunk //: IffChunk //, IBinarySerializable
{
[FieldOrder(0)]
[FieldLength(4)]
public string ChunkName { get; set; }
[FieldOrder(1)]
[SerializeAs(Endianness = Endianness.Big)]
public UInt32 ChunkSize { get; set; }
[FieldOrder(2)]
[FieldLength("ChunkSize")]
[SerializeAs(Encoding = "UTF-8", Endianness = Endianness.Big)] //, SerializedType = SerializedType.ByteArray)]
public RefePayload RefePayload { get; set; }
//public byte[] RefePayload { get; set; }
[Ignore]
public int PadLength
{
get { return (ChunkSize % 2 == 0) ? 0 : 1; }
}
[FieldOrder(3)]
//[SerializeAs(SerializedType = SerializedType.ByteArray)]
//[FieldLength("PadLength")] //, ConverterType = typeof(PadHackConverter)]
//[SerializeAs(SerializedType = SerializedType.ByteArray)]
[SerializeWhen("PadLength", 1)]
//[FieldLength("PadLength")]
public byte Padding { get; set; } =0x00;
//
//public RefeChunk() : base("REFE")
//{
//}
//public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
//{
// throw new NotImplementedException();
//}
//public void Deserialize(Stream st, Endianness endianness, BinarySerializationContext serializationContext)
//{
// BinarySerializer bs = new BinarySerializer();
// EndianAwareBinaryReader br = new EndianAwareBinaryReader(st, Endianness.Big);
// bs.Endianness = Endianness.Big;
// this.ChunkName = new string(br.ReadChars(4));
// this.ChunkSize = br.ReadUInt32();
// this.ChunkVersion = bs.Deserialize<WankyVersion>(st);
// Debug.IndentLevel = 0;
// Debug.WriteLine(this.ChunkName + " size:" + this.ChunkSize + " " + this.ChunkVersion);
// this.RPV3= bs.Deserialize<RPV3>(st);
// this.DBV3= bs.Deserialize<DBV4>(st);
// byte B13 = br.ReadByte();
// this.Reserved13 = B13;
// Debug.WriteLineIf(this.Reserved13 != 13, "!!!!!!!!!!! RESERVED BYTE 13 iS BAD !!!!!!!!!!!! (SLAPS WRIST)");
// if (this.ChunkVersion >= this.MaxVersion)
// {
// Debug.WriteLine("REFE Chunk version is >= 1,3,0 so we are going to parse some more stuff...");
// //OTHER STUFF blah blah
// }
// //if odd size, read an extra byte
// if (ChunkSize % 2 != 0)
// {
// byte stubbbby = br.ReadByte();
// }
// //db
// //a
//}
Surely there is a way to avoid IBinarySerializer for such a simple concept, right?
Serialization of following is running fine! But the deserialization is going wrong! It seems, that the deserialisation of the string property is finished after the first 0 byte. What can I do to solve this problem?
Deserialisation of following bytes
0xFE, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
Returns following object
Bin3Data() { BinType = 254, Ident = "1", Occupancy = BinOccupancy.Unknown }
But expected is
Bin3Data() { BinType = 254, Ident = "1", Occupancy = BinOccupancy.Full }
example class
public enum BinOccupancy
{
/// <summary>
/// The unknown.
/// </summary>
Unknown = 0,
/// <summary>
/// The empty.
/// </summary>
Empty = 1,
/// <summary>
/// The full.
/// </summary>
Full = 2,
}
public class Bin3Data
{
/// <summary>
/// Initializes a new instance of the <see cref="Bin3Data"/> class.
/// </summary>
public Bin3Data()
: base()
{
}
/// <summary>
/// Gets or sets type of the bin
/// </summary>
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt1)]
public byte BinType { get; set; }
/// <summary>
/// Gets or sets ident
/// </summary>
[FieldOrder(1)]
[FieldLength(31)]
[SerializeAs(SerializedType = SerializedType.NullTerminatedString)]
public string Ident { get; set; }
/// <summary>
/// Gets or sets Occupancy
/// </summary>
[FieldOrder(2)]
[SerializeAs(SerializedType = SerializedType.UInt1)]
public BinOccupancy Occupancy { get; set; }
}
test methode
[Test]
public void DeserializeMessage()
{
var serializer = new BinarySerializer() { Endianness = Endianness.Little };
var inBytes = new byte[]
{
0xFE, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
};
var expectedObj = new Bin3Data() { BinType = 254, Ident = "1", Occupancy = BinOccupancy.Full };
Bin3Data actualObj;
using (var stream = new MemoryStream(inBytes))
{
actualObj = serializer.Deserialize<Bin3Data>(stream);
}
if (!expectedObj.Equals(actualObj))
{
Assert.Fail(
string.Format(
CultureInfo.InvariantCulture,
"Objects are not equal. Expected: {0} Result: {1}",
expectedObj.ToString(),
actualObj.ToString()));
}
}
Hi Jeff,
I have updated the BinarySerializer from version 5.0.3 to the latest version. Since that I get an System.InvalidOperationException. Since that I get a System.InvalidOperationException. What is the reason and what should I do so that my code works again.
Cheers
Dirk
System.OverflowException: Der Wert für einen Int32 war zu groß oder zu klein.
bei System.Convert.ToInt32(UInt32 value)
bei System.UInt32.System.IConvertible.ToInt32(IFormatProvider provider)
bei System.Convert.ToInt32(Object value)
bei BinarySerialization.TypeExtensions.ConvertTo(Object value, Type type)
bei BinarySerialization.Graph.ValueGraph.ValueValueNode.ConvertToFieldType(Object value)
bei BinarySerialization.Graph.ValueGraph.ValueValueNode.Deserialize(BinaryReader reader, SerializedType serializedType, Nullable1 length) bei BinarySerialization.Graph.ValueGraph.ValueValueNode.Deserialize(BoundedStream stream, SerializedType serializedType, Nullable
1 length)
bei BinarySerialization.Graph.ValueGraph.EnumValueNode.DeserializeOverride(BoundedStream stream, EventShuttle eventShuttle)
bei BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BoundedStream stream, Func1 maxLengthDelegate, EventShuttle eventShuttle) bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle) --- Ende der internen Ausnahmestapelüberwachung --- bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle) bei BinarySerialization.Graph.ValueGraph.ObjectValueNode.ObjectDeserializeOverride(BoundedStream stream, EventShuttle eventShuttle) bei BinarySerialization.Graph.ValueGraph.ObjectValueNode.DeserializeOverride(BoundedStream stream, EventShuttle eventShuttle) bei BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BoundedStream stream, Func
1 maxLengthDelegate, EventShuttle eventShuttle)
bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle)
--- Ende der internen Ausnahmestapelüberwachung ---
bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle)
bei BinarySerialization.Graph.ValueGraph.RootValueNode.DeserializeOverride(BoundedStream stream, EventShuttle eventShuttle)
bei BinarySerialization.Graph.ValueGraph.ValueNode.DeserializeInternal(BoundedStream stream, Func`1 maxLengthDelegate, EventShuttle eventShuttle)
bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle)
--- Ende der internen Ausnahmestapelüberwachung ---
bei BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle)
bei BinarySerialization.BinarySerializer.Deserialize(Stream stream, Type type, Object context)
bei BinarySerialization.BinarySerializer.Deserialize(Byte[] data, Type type, Object context)
Any interest in getting this up and running with rc2*? Appears to take lots of jumping through hoops in the reflection namespace.
Start tracking whether fields have been visited or not and use this info for both diagnostics and forward multibindings. As an example,
public class FieldLengthMultibindingClass
{
[FieldOrder(0)]
public int Length { get; set; }
[FieldOrder(1)]
[FieldLength("Length")]
[FieldLength("Length2")]
public FieldLengthMultibindingInternalClass Internal { get; set; }
[FieldOrder(2)]
public int Length2 { get; set; }
}
Although this doesn't currently work during derserialization, there really is no reason it couldn't, with the following logic:
The same check concept would allow for CRC checks, if that's something we want...
I just started using this library as it seemed to fit my needs to control the output to a high degree. (I was previously using the Marshal-class).
However, all the objects that I want to serialize and deserialize are immutable, with all the properties set through the constructor. Is there any way to keep them immutable by decorating the parameters of the constructors, or some other way?
We have to exchange data with some external partner which uses a binary protocol with ASCII characters and I am not sure if the de-/serialization can be achieved with the help of the BinarySerializer.
For instance all value fields are separated with the ";" delimiter (ASCII code 0x3B). For example:
class SampleData1
{
string id;
string value1;
int value2;
int value3;
}
initialized for instance with
id = "ID1";
value1 = "abc";
value3 = 7;
(value 2 on purpose not initialized->default value should be used).
According to the required protocol a string can have the meaning "string value" (in this case it is delimited with the string identifier " = 0x22) or "string identifier" (transported without string identifier).
The class above would be binary serialized as (in ASCII printable representation, not hex):
ID1;"abc";;7;
To get things even more complicated, lists (arrays) are also supported. The arrays are delimited with "[" and "]" and the array elements are separated with ",". The aggregate types (classes) are additionally delimited with "{" and "}".
For example an array of 2 SampleData2 elements (the number of array elements is dynamic, and should be determined by the BinarySerializer by recognizing the "[" and "]" delimiters), where SampleData2 is defined as:
class SampleData2
{
SampleData1 data1;
int var1;
}
would be serialized to (in ASCII printable representation) as:
[{{ID1;"abc";;7;};3},{{ID2;"def";;;};44}]
(in this example var1 is 33 in the first array element and 44 in the second)
The classes and arrays can be hierachically cascaded (that means classes may contain other classes or arrays and so on).
Would be possible to implement such a protocol with BinarySerializer ? Are there any samples for similar protocol available ?
I can think of a few use cases where endianness is specificed within the format.
I'd be awesome if endianness could be loaded from a variable!
Hello, first of all I am sorry if this isn't the correct place to ask, I am not so familiar with github.
This framework is amazing, I'm glad that I found it, but I am a bit confused about Value Converter.
I have a packet structure where one of its props is the payload length (as UInt16), it comes "ciphered" (xor with 0x1357) and I am not sure if this is the proper use for a Value Converter.
This is most because I don't get why I can't set a ConverterType for FieldOrder, maybe because the length result from the convert may be different of the field size?
I know I can set a the converter as a proper of FieldSize but then I am defining the size two times because I already have set the variable as UInt16.
Anyway, really sorry if this is not the correct place or my question offends you (I don't know if my question is stupid), I readed the readme many times but I don't get it.
Thank!
EDIT: nvm, I misunderstood all, value converter is for bindings (#19). Seems like the proper way to do this is having some method that "cipher" all the header before serializing the packet, and decipher after deserializing it.
Looks like I did not read well all readme (excuse me, english is not my native language).
EDIT2: I think this will be a good moment to use a custom serialization, What do you think? The code will be cleaner and will abstract all the packet processing (encryption, compression and checksum), is there something I am missing or its so good as it sounds?
Just a feature request, but it would be cool to get your thoughts.
-thanks
-e
I did some measurements regarding the performance of the BinarySerializer serialization/deserialization, and I got quite huge times for the deserialization.
A binary message with some about 10000 bytes needs each time about 1200 msec for deserialization (the BinarySerializer object is created only once and reused, no debugger events were defined during this measurement).
What is weird is that the serialization process that generates the 10000 bytes back from the c# class takes only 10 msec or even less.
Only the deserialization of each length-prefixed string takes 15 msec (to get these times I had to reactivate the debug events)
2015-03-23T10:56:32.7437607+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserializing B_ID, stream offset 0
2015-03-23T10:56:32.7447608+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserialized B_ID, (300101000), stream offset 4
2015-03-23T10:56:32.7477611+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserializing B_Name, stream offset 4
2015-03-23T10:56:32.7497613+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserializing Length, stream offset 4
2015-03-23T10:56:32.7527616+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserialized Length, (2), stream offset 6
2015-03-23T10:56:32.7577621+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserializing Value, stream offset 6
2015-03-23T10:56:32.7607624+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserialized Value, (W1), stream offset 10
2015-03-23T10:56:32.7627626+01:00 [DEBUG] BinarySerialization.BinarySerializer -
Deserialized B_Name, (W1), stream offset 55
The c# class looks like this:
public class Entry
{
[FieldOrder(0)]
public byte Length { get; set; }
[FieldOrder(1)]
[FieldLength("Length")]
public string Value { get; set; }
}
public class ElementClass
{
[FieldOrder(0)]
public Int32 B_ID { get; set; }
[FieldOrder(1)]
[FieldLength(51)]
public Entry B_Name { get; set; }
...
}
Earlier I had this code to get the length-prefixed string by reading "manually" the length from the first byte:
...
private string _B_Name;
[FieldOrder(1)]
[FieldLength(51)]
[SerializeAs(Encoding = "UTF-8")]
public string B_Name //{ get; set; }
{
get
{
return this._B_Name;
}
set
{
this._B_Name = LengthPrefixedStringToString(value);
}
}
...
where:
internal static string LengthPrefixedStringToString(string value)
{
string tempStr = String.Empty;
if (value != null)
{
try
{
value.Trim();
int strLen = value.Length;
if (strLen > 0)
{
if (strLen > 255) {
throw new Exception("Maximum length allowed for pascal strings is 255");
}
char lenCh = value[0];
byte len = Convert.ToByte(lenCh);
if (strLen > (int)len)
{
tempStr = value.Substring(1, len);
}
}
}
catch { }
}
return tempStr;
}
With this code, the deserialization of the 10000 bytes from the binary message takes only 30 msec or even less (still not perfect, if I compare to the serialization time in the other direction, but much much better than the 1200 msec above).
Is there any way to significantly improve the performance of the deserializer, especially regarding such length-prefixed strings, constructed as above ?
It would be nice if you could specify a default subtype for unknown subtype values.
Could you please add also a generic serializer Serialize< T > (Stream stream, T value) method to the BinarySerializer class ? I could find only the T Deserialize< T >(...) generic method.
It seems that the reserved field length for a string is ignored if the string is null. If the string is empty, it works fine.
[FieldLength(50)]
[SerializeAs(Encoding = "ASCII")]
public string Data { get; set; }
Assume the following:
OrderAdditionalKegs only needs to be Serialized when PartyBusIsComing == true AND
ModelsAtPlayHouseMansion >= 20
[FieldOrder(0)]
public int ModelsAtPlayHouseMansionCount {get; set;}
[FieldOrder(1)]
public bool PartyBusIsComing {get; set;}
[FieldOrder(2)]
[SerializeWhen("ModelsAtPlayHouseMansionCount", true, ConverterParameter = "20", ConverterType = typeof(GreaterOrEqualConverter))]
[SerializeWhen("PartyBusIsComing", true)]
public bool OrderAdditionalKegs {get; set;}
This will not work because SerializeWhen are always ||'d together.
Can you show an example where a converter accepts more than one argument?
MySource.txt
exceptionWhileSerialize.txt
exceptionWhileDeserialize.txt
public enum LoadCarrierType
{
/// <summary>
/// unknown
/// </summary>
Unknown = 0,
/// <summary>
/// bin 1
/// </summary>
Bin1 = 1,
/// <summary>
/// bin 2
/// </summary>
Bin2 = 2,
/// <summary>
/// palette
/// </summary>
Palette = 3,
/// <summary>
/// pipe
/// </summary>
Pipe = 4
}
public class LoadCarrierData
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="LoadCarrierData"/> class.
/// </summary>
public LoadCarrierData()
{
}
#endregion
#region public properties
/// <summary>
/// Gets or sets type of the load carrier
/// </summary>
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt4)]
public LoadCarrierType CarrierType { get; set; }
/// <summary>
/// Gets or Sets the data
/// </summary>
[FieldOrder(1)]
[Subtype("CarrierType", LoadCarrierType.Unknown, typeof(object))]
[Subtype("CarrierType", LoadCarrierType.Bin1, typeof(Bin1Data))]
[Subtype("CarrierType", LoadCarrierType.Bin2, typeof(Bin2Data))]
[Subtype("CarrierType", LoadCarrierType.Palette, typeof(PalData))]
[Subtype("CarrierType", LoadCarrierType.Pipe, typeof(PipeData))]
public object Data { get; set; }
#endregion
}
I have defined a class that holds different objects in the property Data. See attached file MySource.txt. I use the SubtypeAttribute and have defined the different objects. That leads to exception during serialization and derserialization.
Is there something wrong in my class defintion? Please keep me informed!
Regards
Dirk (@Anhaltiner0708)
Rather than having to write code, I want to say
[FieldEndianness("Endianness", 0x1A2B3C4D, Endianness.Big)]
Sorry, Posted to wrong repository.
Bindings targets to multiple sources can be generalized, even for subtype attributes. The only restriction should be that bindings with the same configuration must agree between multiple sources.
It would be really helpful, if the BinarySerializer would track the actual stream position, aditionally to the name of the deserialized node. Could you please add the position in the binary stream in the OnMemberDeserializing event ?
Doing way too much to support the stupid ngpcap format. Now probably need deferred length calculation to support late binding of endianness...
It will be very nice if BinarySerializer
supports checksum or custom function.
[FieldOrder(0)]
public byte FieldA { get; set; }
[FieldOrder(1)]
public byte FieldB { get; set; }
[FieldOrder(2)]
public byte FieldC { get; set; }
[FieldOrder(3)]
[Checksum] // or [CustomFunc(myFunc)]
public byte Checksum { get; }
It may be similar to [FieldLength("Length")]
, which Length
could be generated and overwriten in serializing progress.
I attempted serializing the following object
[Serializable]
public class smallCase
{
[FieldOrder(0)]
public DateTime updateTime { get; set; }
}
The call to Serialize thinks a while and then reports a stackoverflow error.
The code being executed is simply
smallCase sC = new smallCase();
using (MemoryStream ms = new MemoryStream())
{
BinarySerializer bs = new BinarySerializer();
bs.Serialize(ms, sC); // << stack overflow here
}
I may have misunderstood how to use a value converter during serialization. I have a field that should be serialized to a UInt, but deserialized to a DateTime.
I have a class that is defined like so:
public class ValueUpdateMessage
{
[FieldOrder(0)]
public UInt TimeStamp { get; set; }
[FieldOrder(1)]
public byte NewValue { get; set; }
}
Since I am working with .Net and DateTime, I would like to change my representation of the message to
public class ValueUpdateMessage
{
[FieldOrder(0)]
public DateTime TimeStamp { get; set; }
[FieldOrder(1)]
public byte NewValue { get; set; }
}
since that makes date times easier to work with. As of now, I can achieve this by introducing an extra member:
public class ValueUpdateMessage
{
[Ignore]
public DateTime TimeStamp
{
get { return ConvertToDateTime(UnixTimeStamp); }
set { UnixTimeStamp = ConvertToUnixTime(value); }
}
[FieldOrder(0)]
public DateTime UnixTimeStamp { get; set; }
[FieldOrder(1)]
public byte NewValue { get; set; }
}
However, it would be a lot cleaner to use the class as defined in 2
. I saw the example with a value converter in the Readme, but I can't get it to work. The FieldOrder attribute does not have the ConverterType field, so I tried using one of the others, such as
[FieldOffset(0, ConverterType = typeof(DateTimeToUnixTimestampConverter)]
, and
[FieldLength(4, ConverterType = typeof(DateTimeToUnixTimestampConverter)]
Is there a straight forward way to do this?
I'm attempting to deserialize from a NetworkStream. In my case, I'm using the SubType attribute to target a type that contains an IBinarySerializable type.
Take a look here
Does this look right? Maybe there is a better way of going about this.
Thanks,
-james
System.InvalidOperationException occurred
HResult=0x80131509
Message=Error deserializing 'type 'BinarySerializerRepro.ChunkContainer''. See inner exception for detail.
Source=BinarySerializer
StackTrace:
at BinarySerialization.Graph.ValueGraph.ValueNode.Deserialize(BoundedStream stream, EventShuttle eventShuttle)
at BinarySerialization.BinarySerializer.Deserialize(Stream stream, Type type, Object context)
at BinarySerialization.BinarySerializer.Deserialize[T](Stream stream, Object context)
at BinarySerializerRepro.Program.Main(String[] args) in E:\src\BinarySerializerRepro\Program.cs:line 149
Inner Exception 1:
InvalidOperationException: Error deserializing 'type 'BinarySerializerRepro.ChunkContainer''. See inner exception for detail.
Inner Exception 2:
InvalidOperationException: Error deserializing 'member 'Chunk''. See inner exception for detail.
Inner Exception 3:
InvalidOperationException: Error deserializing 'member 'Customs''. See inner exception for detail.
Inner Exception 4:
InvalidOperationException: Not supported on non-seekable streams
I am getting a compatibility error message when I try to install the BinarySerializer package in a WindowsPhone 8.1 project. Should a PCL (portable) class library not work also for WinPhone 8.1 ?
Hi Jeff,
As I understand FieldAlignment attribute sets both left and right alignment. I did not find how to set just left alignment, not both (I need it to describe DCE RPC message). Is it possible now?
Thank you in advance.
The serialization of the following object leads to an stack overflow.
public enum LoadCarrierType
{
/// <summary>
/// unknown
/// </summary>
Unknown = 0,
/// <summary>
/// bin 1
/// </summary>
Bin1 = 1,
/// <summary>
/// bin 2
/// </summary>
Bin2 = 2,
/// <summary>
/// palette
/// </summary>
Palette = 3,
/// <summary>
/// pipe
/// </summary>
Pipe = 4
}
public class LoadCarrierData
{
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="LoadCarrierData"/> class.
/// </summary>
public LoadCarrierData()
{
}
#endregion
#region public properties
/// <summary>
/// Gets or sets type of the load carrier
/// </summary>
[FieldOrder(0)]
[SerializeAs(SerializedType = SerializedType.UInt4)]
public LoadCarrierType CarrierType { get; set; }
/// <summary>
/// Gets or sets the BinData 1.
/// </summary>
[FieldOrder(1)]
[SerializeWhen("CarrierType", LoadCarrierType.Bin1)]
public Bin1Data Bin1 { get; set; }
/// <summary>
/// Gets or sets the BinData 2.
/// </summary>
[FieldOrder(2)]
[SerializeWhen("CarrierType", LoadCarrierType.Bin2)]
public Bin2Data Bin2 { get; set; }
/// <summary>
/// Gets or sets the pallet data.
/// </summary>
[FieldOrder(3)]
[SerializeWhen("CarrierType", LoadCarrierType.Palette)]
public PalData PalletData { get; set; }
/// <summary>
/// Gets or sets the pallet data.
/// </summary>
[FieldOrder(4)]
[SerializeWhen("CarrierType", LoadCarrierType.Pipe)]
public PipeData PipeData { get; set; }
/// <summary>
/// Gets or Sets the data
/// </summary>
[Ignore]
public object Data { get; set; }
#endregion
}
Testmethod
public void SerializeUnknownMessageLittleEndian2()
{
var expetedBytes = new byte[] { 0x00, 0x00, 0x00, 0x00 };
var obj = new LoadCarrierData() { Data = new object() };
var serializer = new BinarySerializer() { Endianness = Endianness.Little };
byte[] actualBytes = null;
using (var stream = new MemoryStream())
{
serializer.Serialize(stream, obj);
actualBytes = stream.ToArray();
}
if (!expetedBytes.SequenceEqual(actualBytes))
{
Assert.Fail(
string.Format(
CultureInfo.InvariantCulture,
"Bytes are not equal. Expected({2}): {0} Result({3}): {1}",
BitConverter.ToString(expetedBytes),
BitConverter.ToString(actualBytes),
expetedBytes.Length,
actualBytes.Length));
}
}
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<App.Subsystem.Conveyor.Messages.DataTypes.PositionData> posData) Zeile 87 C#
[Übergang von Systemeigen zu Verwaltet]
[Übergang von Verwaltet zu Systemeigen]
BinarySerializer.dll!BinarySerialization.Graph.ValueGraph.ObjectValueNode.GetValue(System.Func<BinarySerialization.Graph.ValueGraph.ValueNode, object> 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<BinarySerialization.BinarySerializationContext>.CreateValue() Unbekannt
mscorlib.dll!System.Lazy<BinarySerialization.BinarySerializationContext>.LazyInitValue() Unbekannt
mscorlib.dll!System.Lazy<BinarySerialization.BinarySerializationContext>.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<App.Subsystem.Conveyor.Messages.States.MachineState>(System.IO.Stream stream, object context) Unbekannt
Plat.System.BinarySerializerHelper.dll!Plat.System.BinarySerializerHelper.BinarySerializerHelper.BinaryDeserializeMessage<App.Subsystem.Conveyor.Messages.States.MachineState>(byte[] msgBin) Zeile 156 C#
App.Subsystem.Conveyor.NUnit.dll!App.Subsystem.Conveyor.NUnit.Common.MsgBaseTests.DeserializeMessageBigEndian<App.Subsystem.Conveyor.Messages.States.MachineState>(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]
in my app the BinarySerializer is used for Serialization of Tcp/Ip communication, one TargetParameterCountException is thrown while calling Deserialize method. i have prepared a simple Project for test it, there is 3 constructors in Header.cs, if the both constructors with Parameters are commented out, no exceptions occur, otherwise, one TargetParameterCountException is from code line
value = subType.Constructor.Invoke(parameterValues) in class ObjectValueNode thrown.
i can't attach source code per zip, so i wrote it in one txt file, which has 7 simple .cs files, please have Patience!
Thanks
Depending on the type of binding and mode it may make sense to add a forward binding check. We need a better way of describing the nature of bindings and whether or not forward bindings are allowed. For example, endianness is valid for forward bindings but length is not. Need to think about this...
I have a class as follows:
public class InputsStateFrameData : FrameData
{
public InputsStateFrameData(bool[] inputs)
{
//Debug.Assert(inputs.Count == 16, "There should be 16 inputs.");
Inputs = inputs;
}
[FieldCount(16)]
public bool[] Inputs { get; }
}
It's a part of a full message frame, and I can serialize whole frame using BinarySerializer without problems. When I try to deserialize serialized byte stream or prepared array of bytes:
0xFF,
0x13,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0xFE
I get InvalidOperationException with inner ArgumentException:
Additional information: Cannot widen from source type to target type either because the source type is a not a primitive type or the conversion cannot be accomplished.
It is thrown by the Array.SetValue method in SetCollectionValue method from PrimitveArrayValueNode
protected override void SetCollectionValue(object item, int index)
{
var array = (Array)BoundValue;
array.SetValue(item, index);
}
When I tried replacing array by List it doesn't work anyway, just the exceptions are different:
The value "0" is not of type "System.Boolean" and cannot be used in this generic collection
This method tries to set boolean value with byte without any conversion, so it throws exceptions like that.
I am wondering why this part:
var items =
DeserializeCollection(stream, eventShuttle).ToList();
var itemCount = items.Count;
/* Create final collection */
Value = CreateCollection(itemCount);
/* Copy temp list into final collection */
for (var i = 0; i < itemCount; i++)
SetCollectionValue(items[i], i);
Is implemented that way, iterating with SetCollectionValue instead of just using CreateCollection with items enumerable, which uses TypeConverters.ConvertTo method to convert deserialized value into the collection child type.
Both top-level graph management and subtype management could probably benefit from concurrentdictionary
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.