使用 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>