All,
I am using ZeroFormatter for serialization of a big object, sometimes it is giving following error while serializing the error, this issue is observed after using Union concept of ZeroFormatter for inheritence.
Here are the exception details:
System.InvalidProgramException: Common Language Runtime detected an invalid program.
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Factors.RateFactor$Formatter.Serialize(Byte[]& , Int32 , RateFactor )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.RateClass$Formatter.Serialize(Byte[]& , Int32 , RateClass )
at ZeroFormatter.Formatters.CollectionFormatter
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackagePlan$Formatter.Serialize(Byte[]& , Int32 , PackagePlan )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Package$Formatter.Serialize(Byte[]& , Int32 , Package )
at ZeroFormatter.Formatters.CollectionFormatter
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackageGroup$Formatter.Serialize(Byte[]& , Int32 , PackageGroup )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
1.Serialize[T](T obj)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Group.GroupRatingResults$Formatter.Serialize(Byte[]& , Int32 , GroupRatingResults )
at ZeroFormatter.ZeroFormatterSerializer.CustomSerializer
at Colibrium.Utility.Library.ObjectConverter`1.ConvertO bjectToBinaryZeroFormatter(T p_object)in C:\TFS\UPMC\Repos\Colibrium.Utility.Library\ObjectConverter.cs:line 407
Looking at the source code for DynamicFormatter it appears the library tries to optimize formatting of your user types by generating CLR types at runtime to serialize / deserialize the user type to a byte array. Based on the error, it seems there must be a bug in this IL generation.
You should report this problem in the ZeroFormatter project issues but note you will likely need to have a good way to reproduce this issue, as tracking down an
InvalidProgramException
is very challenging.