diff --git a/src/Hyperion/Hyperion.csproj b/src/Hyperion/Hyperion.csproj index 7dccf116..803258d0 100644 --- a/src/Hyperion/Hyperion.csproj +++ b/src/Hyperion/Hyperion.csproj @@ -32,6 +32,10 @@ + + + + $(DefineConstants);NETSTANDARD16 diff --git a/src/Hyperion/ValueSerializers/ObjectSerializer.cs b/src/Hyperion/ValueSerializers/ObjectSerializer.cs index fe53fbfc..6d936bd7 100644 --- a/src/Hyperion/ValueSerializers/ObjectSerializer.cs +++ b/src/Hyperion/ValueSerializers/ObjectSerializer.cs @@ -10,6 +10,7 @@ using System; using System.IO; using System.Linq; +using System.Runtime.Serialization; using System.Threading; using Hyperion.Extensions; @@ -103,7 +104,18 @@ public override void WriteManifest(Stream stream, SerializerSession session) public override void WriteValue(Stream stream, object value, SerializerSession session) => _writer(stream, value, session); - public override object ReadValue(Stream stream, DeserializerSession session) => _reader(stream, session); + public override object ReadValue(Stream stream, DeserializerSession session) + { + try + { + return _reader(stream, session); + } + catch (Exception e) + { + throw new SerializationException( + $"Failed to deserialize object of type [{Type}] from the stream. Cause: {e.Message}", e); + } + } public override Type GetElementType() => Type;