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
Developer Community or GitHub 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.
I'm using Xamarin.Forms.Windows.188.8.131.5253-pre2.
When I call Device.BeginInvokeOnMainThread on a background thread of a WinPhone 8.1 app, then a NullReferenceException is thrown.
The stack trace looks like this:
System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.WinRT.WindowsBasePlatformServices.BeginInvokeOnMainThread(Action action)
at Xamarin.Forms.Device.BeginInvokeOnMainThread(Action action)
at MR.Gestures.GestureHandler.ExecuteCommand(ICommand command, Object parameter, BaseGestureEventArgs args)
And my code:
if (command != null && command.CanExecute(parameter))
Device.BeginInvokeOnMainThread(() => command.Execute(parameter));
System.Diagnostics.Debug.WriteLine("Exception in ExecuteCommand:\n" + ex.ToString());
The same code works on the other platforms. It also works on WinPhone 8.1, if it is run in the main thread.
This bug has also been reported by Phil Russell in https://forums.xamarin.com/discussion/38167/xf-for-winphone8-1-rt-preview-begininvokeonmainthread-broken
*** This bug has been marked as a duplicate of bug 29158 ***