I'm attempting to deserialize a Codification object but it throws the following error.
Object reference not set to an instance of an object.
at Accord.Collections.TwoWayDictionary`2.OnDeserialized(StreamingContext context) in D:\Accord.NET.3.2.0\Sources\Accord.Core\Collections\TwoWayDictionary.cs:line 457
at System.Runtime.Serialization.SerializationEventHandler.Invoke(StreamingContext context)
at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent()
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)
Here's the code I'm using to deserialize:
fs = New FileStream(Application.StartupPath & "\cb.dat", FileMode.Open)
bf = New BinaryFormatter()
codebook = CType(bf.Deserialize(fs), Codification)
fs.Close()
And what I am using to serialize:
fs = New FileStream(Application.StartupPath & "\cb.dat", FileMode.CreateNew)
bf = New BinaryFormatter()
bf.Serialize(fs, codebook)
fs.Close()
I'm able to successfully serialize/deserialize the NaiveBayes and DataTable objects with the same code so I don't believe that's the issue.