I recently wrote a code for copying a class with C5 library "IntervalHeap" but encountered an error message like this.
System.Runtime.Serialization.SerializationException: 'Type 'C5.IntervalHeap`1+Interval[[TransSys1.Node, TransSys1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'C5, Version=2.5.0.0, Culture=neutral, PublicKeyToken=282361b99ded7e8e' is not marked as serializable.'
I checked the source code in here but the IntervalHeap class is already labeled as [Serializable]
. I built the source code again but it still not working. I debugged my project with x64 platforms.
Can you let me know what are the potential reasons or how to solve it?
The exception message points to the Interval
struct, defined as inner struct within C5.IntervalHeap<T>
noted as
C5.IntervalHeap`1+Interval
You get this error because this Interval
struct is not marked Serializable
.
Unless you own that source (maybe via a copy) there isn't much you can do about it.
Maybe find another way to take a copy, without serializing.