【问题标题】:VerificationException "Operation could destabilize runtime" Error with MsgPack and .net ErrorVerificationException“操作可能破坏运行时”错误与 MsgPack 和 .net 错误
【发布时间】:2013-03-13 10:44:36
【问题描述】:

使用 MsgPack 序列化某些 F# 类型时遇到 VerificationException“操作可能破坏运行时”错误。编译器还建议可能会加载冲突的类库,但这似乎是一个红鲱鱼。

目前尚不清楚错误是由什么引起的,因此为了社区利益,请在下面发布解决方案。


回应以下评论:

....Sammo\bin\Debug>peverify /verbose Sammo.exe

Microsoft (R) .NET Framework PE Verifier.  Version  4.0.30319.17929
Copyright (c) Microsoft Corporation.  All rights reserved.

All Classes and Methods in Sammo.exe Verified.



....Sammo\bin\Debug>Sammo.exe
Unhandled Exception: System.Security.VerificationException: Operation could destabilize the runtime.
   at _4(MsgPackReader )
   at _3(MsgPackReader )
   at MsgPack.CompiledPacker.Unpack[T](Stream strm)
   at MsgPack.CompiledPacker.Unpack[T](Byte[] buf, Int32 offset, Int32 size)
   at MsgPack.CompiledPacker.Unpack[T](Byte[] buf)
   at <StartupCode$Sammo>.$Program.main@() in ....\Sammo\Pro
gram.fs:line 67

....\Sammo\bin\Debug>

【问题讨论】:

  • 您可以在您编译的程序集上运行peverify --verbose 并在此处发布结果(如果有任何错误)? (如果您之前没有使用过peverify,则需要从 Visual Studio 命令提示符而不是普通命令提示符运行它。

标签: c# f# msgpack


【解决方案1】:

问题在于 MsgPack,一个序列化库不支持特定的 DateTime 格式或约定。

但是,错误消息输出具有误导性,只有当您深入研究异常时,您才能找到有关正在发生的事情的更多线索。

作为一种替代解决方案,可以改为使用 Unix 时间戳或 .Net Ticks [100ns] 概念作为具有适当成员定义的基础值/字段来公开 System.DateTime。

【讨论】:

  • 嗯,DateTime 不是模板,也不是属性。一个非常简单的类型,自 .NET 1.0 以来它没有改变。听起来您并没有发现真正的问题。
  • 恐怕我没有把问题说清楚——问题是 MsgPack 库不支持序列化 System.DateTime 类型,但我认为 VisStudio 产生的错误有点具有误导性,可能值得跟进。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-22
相关资源
最近更新 更多