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.
In my view model, if I run:
var coder = new Geocoder();
var partnerPosition = (await coder.GetPositionsForAddressAsync(partner.Address)).FirstOrDefault();
I get a cross-thread execution exception. If I try to wrap the code in Device.BeginInvokeOnMainThread, it executes but returns no results. I can successfully call the above code in the constructor of a Page, and it executes correctly.
This is a limitation of the underlying platform. However, given that the method returns a task, there is no need to initiate it on a separate thread to begin with.
I am not initiating it on a separate thread. I get the cross-thread exception when I make the call from a method in my view model that is being called from the OnBindingContextChanged event of my page.
The exception is coming from the underlying platform. I have double checked it throws this exception if you call from a thread, please validate your code is indeed on the main thread. (Setting the BindingContext from a thread could for example trigger OnBindingContextChanged on a thread).
Please re-open if you can provide a stacktrace of the exception being in the UI thread.