serialization - System.InvalidProgramException:公共语言运行时检测到无效程序
问题描述
全部,
我正在使用 ZeroFormatter 对大对象进行序列化,有时在序列化错误时会出现以下错误,在使用 ZeroFormatter 的 Union 概念进行继承后会观察到此问题。
以下是异常详细信息:
System.InvalidProgramException:公共语言运行时检测到无效程序。
在 ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Factors.RateFactor$Formatter.Serialize(Byte[]& , Int32 , RateFactor )
在 ZeroFormatter.Formatters.CollectionFormatter 3.Serialize(Byte[]& bytes, Int32 offset , TCollection 值) 在 ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackagePlan$Formatter.Serialize(Byte[]& , Int32 , PackagePlan ) 在 ZeroFormatter.Formatters.CollectionFormatter 3.Serialize(Byte[]& bytes, Int32 偏移量,TCollection 值)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.CollectionFormatter3.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
在 ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackageGroup$Formatter.Serialize(Byte[]& , Int32 , PackageGroup )
在 ZeroFormatter.Formatters.CollectionFormatter 1.Serialize[T](T obj) 在 Colibrium.Utility .Library.ObjectConverter`1.ConvertO bjectToBinaryZeroFormatter(T p_object)3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Group.GroupRatingResults$Formatter.Serialize(Byte[]& , Int32 , GroupRatingResults )
at ZeroFormatter.ZeroFormatterSerializer.CustomSerializer在 C:\TFS\UPMC\Repos\Colibrium.Utility.Library\ObjectConverter.cs:407 行
解决方案
查看DynamicFormatter的源代码,似乎该库试图通过在运行时生成 CLR 类型来将用户类型序列化/反序列化为字节数组来优化用户类型的格式。根据错误,这代 IL 似乎一定存在错误。
您应该在ZeroFormatter 项目问题中报告此问题,但请注意,您可能需要有一个重现此问题的好方法,因为追踪一个InvalidProgramException
非常具有挑战性。
推荐阅读
- sql - 将 2 个表连接在一起并插入新表的 SQL 语句(sqlite)
- javascript - 在 PHP 中从网格中获取 id
- c++ - 使用指针计算堆栈问题的大 O 表示法
- python - 使用 urllib2.urlOpen() 创建连接超时
- php - 如何计算 Kubernetes 集群上的 php-fpm 子进程
- pointers - 当 p 是指针时,Go 中的 p 和 &p 有什么区别?
- android - 在 android 中使用改造将数据保存到 mysql 后端(POST)
- android - 是否可以直接在 Android 设备上构建 Android 应用程序?
- django - 将新用户添加到刚刚创建的对象
- firebase - 从 Firebase 云函数获取响应