I'm deserializing an object and in certain cases it works fine, however in others it fails. The exception is essentially meaningless to me, but there has to be a way to figure out where exactly it failed so i redirect my debugging.
This is the exception:
System.Runtime.Serialization.SerializationException was caught Message="No map for object '201326592'."
Source="mscorlib" StackTrace: at System.Runtime.Serialization.Formatters.Binary._BinaryParser.ReadObject() at System.Runtime.Serialization.Formatters.Binary._BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at Analytics.ReportInstance.Open(Stream tStream, Boolean OpenResults) in C:\Users...path...\File.vb:line 149 InnerException:
And this is the source code where it is trapped:
Public Shared Function Open(ByVal tStream As IO.Stream, Optional ByVal OpenResults As Boolean = False) As ReportInstance
Dim tFormatter As System.Runtime.Serialization.Formatters.Binary.BinaryFormatter = PluginSerializationBinder.CreateSerializer()
Dim tInstance As ReportInstance
Try
If OpenResults Then 'case which always fails
'open the entire report
If System.Diagnostics.Debugger.IsAttached Then
Console.WriteLine("Deserializing: report results")
End If
tInstance = tFormatter.Deserialize(tStream) 'throws exception here
Return tInstance
Else 'case which always works (only deserializing part of the object)
'just open the stub
If System.Diagnostics.Debugger.IsAttached Then
Console.WriteLine("Deserializing: report instance")
End If
Dim tInput As New IO.BinaryReader(tStream)
Dim tLength As Long = tInput.ReadInt64()
Dim tBytes() As Byte = tInput.ReadBytes(tLength)
Dim tMem As New IO.MemoryStream(tBytes)
tInstance = tFormatter.Deserialize(tMem)
Return tInstance
End If
Catch ex As Exception
If (ex.Message.Contains("blah")) Then
Throw New UnsupportedException(ex.Message)
Else
Throw 'trapped here
End If
End Try
End Function
Thanks, brian