I'm experiencing a very interesting UWP "bug".
I'm using Xamarin.Forms 2.3.3.193 and I need to list the contacts from the device. In the UWP project everything works fine if it's compiled in Debug, but it doesn't work anymore if it's compiled in Release (of course Android and iOS are working fine always).
These are the 2 lines of code of the UWP service that lists the contacts:
ContactStore store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly);
IReadOnlyList<Contact> contacts = await store.FindContactsAsync();
The FindContactsAsync() method returns the list when in debug but returns null when in release.
I also used the Xamarin.Plugin.Contacts from James Montemagno, but suffers the same fate.
Moreover, I tried the solution offered here without any luck.
Any suggestion?
This might occur when using the
Compile with .NET Native tool chain
which is an option for UWP apps in the Properties > Build > General window for the project.Try to uncheck this option.
You tried to do this but it did not work for you. This should work according to this article.
Try changing your App.xaml.cs file in your UWP project follwing this: