Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 5958 [details]
Patch to DispatcherOperation
Executing a code like this:
dispatcher.BeginInvoke(DispatcherPriority.Normal, someDelegate, arg1, arg2);
causes the following exception:
at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x0020f]
at System.Windows.Threading.DispatcherOperation..ctor (System.Windows.Threading.Dispatcher dis, DispatcherPriority prio, System.Delegate d, System.Object arg, System.Object args) [0x0002a]
at System.Windows.Threading.Dispatcher.BeginInvoke (DispatcherPriority priority, System.Delegate method, System.Object arg, System.Object args) [0x00041]
After studying the source code, the bug appears in the DispatcherOperation constructor:
internal DispatcherOperation (Dispatcher dis, DispatcherPriority prio, Delegate d, object arg, object  args)
: this (dis, prio)
delegate_method = d;
delegate_args = new object [args.Length + 1];
delegate_args  = arg;
Array.Copy (args, 1, delegate_args, 0, args.Length);
When the array is copied, the source and the destination indexes are confused.
I have attached the patch.