mono 4.x 中的反射发生了什么变化? (与单声道 3.x 的兼容性)

What is changed about reflection in mono 4.x? (compatibility with mono 3.x)

我的单声道 4 例外:

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke) <Module>:invoke_callvirt_CancellationTokenRegistration_CancellationToken&_Action`1<object>_object (System.Threading.CancellationToken&,System.Action`1<object>,object): IL_0057: castclass 0x00000007

此处提供更多详细信息:https://github.com/Anthilla/Antd/issues/8

单声道 3.2.x, 3.12.1 and other 3.x 一切正常,但从 4.0.0-beta 开始(4.0.14.0.1.28)我遇到了这个奇怪的异常。

所以我想知道是否没有 IL 兼容性,那么如何使用 nuget? 4.x 中的反射发生了什么变化?

同样的问题在这里:Issue after updating to mono 4.0.1 on Ubuntu

来自http://www.mono-project.com/docs/about-mono/releases/4.0.0/

  • 采用微软开源代码
  • C# 6.0
  • 浮点优化
  • 我们放弃了对 2.0、3.5 和 4.0 程序集的支持
  • 已更新 IKVM
  • 更轻的调试器开销
  • 基本的 PowerPC64 LE 支持

(我加了粗体)

他们将许多 类 从他们的 ("original" Mono) 实现更改为 Microsoft 的 (http://referencesource.microsoft.com),如此多的 "hacks" 是为了兼容Mono 现在是非功能性的,因为使用的 CLR 库是 Microsoft 的,他们可能引入了新的错误,因为他们甚至更改了参考源中的一些代码以使其兼容。这是一个 "stop the train, change the world" 版本。

与此提交相关:https://github.com/mono/mono/commit/ae495e8bd485f48ecdb7e53d7e98771220f31997

还有这个错误:https://bugzilla.xamarin.com/show_bug.cgi?id=29665

但是构建 4.0.1.28 来自分支 4.0.0 而不是来自 master 所以那里没有这个修复,它将在 4.1 中修复 // 这个答案的学分 来自 mono gitter 的 David Karlas

master

的单声道一切正常