Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Deserialize of Codification error in 3.2.0 #285

@spoved1

Description

@spoved1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions