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

0

My exception with mono 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

more details available here: https://github.com/Anthilla/Antd/issues/8

Everything builds fine with mono 3.2.x, 3.12.1 and other 3.x but starting from 4.0.0-beta (4.0.1, 4.0.1.28) I'm getting this strange exception.

So I wonder if there there is no IL compatibility and so then how it possible to use nuget? What is changed about reflection in 4.x?

same issue is here: Issue after updating to mono 4.0.1 on Ubuntu

c#
.net
mono
asked on Stack Overflow May 9, 2015 by cnd • edited May 23, 2017 by Community

2 Answers

1

Related this commit: https://github.com/mono/mono/commit/ae495e8bd485f48ecdb7e53d7e98771220f31997

and this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=29665

But build 4.0.1.28 is from branch 4.0.0 and not from master so there is no this fix there and it will be fixed in 4.1 // credits for this answer goes to David Karlas from mono gitter

everything work well with mono from master

answered on Stack Overflow May 9, 2015 by cnd • edited May 9, 2015 by cnd
0

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

  • Adoption of Microsoft’s open source code
  • C# 6.0
  • Floating point optimizations
  • We dropped support for the 2.0, 3.5 and 4.0 assemblies
  • Updated IKVM
  • Lighter Debugger overhead
  • Basic PowerPC64 LE support

(I added the bold)

They changed many classes from their ("original" Mono) implementations to the Microsoft ones (http://referencesource.microsoft.com), so many "hacks" that were present to be compatible with Mono are now non-functional, because the CLR libraries used are Microsoft ones, and they probably introduced new bugs, because they even changed some code in the reference source to make it compatible. It was a "stop the train, change the world" version.

answered on Stack Overflow May 9, 2015 by xanatos

User contributions licensed under CC BY-SA 3.0