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.
While using ABPeoplePickerNavigationController, in very rare cases the app will crash.
This Apple vCard is an export of one of the particular details which will cause the app to crash.
I believe the issue is to do with linq. This is what I have discovered so far.
1. While using the SelectPerson event of ABPeoplePickerNavigationController the app will crash with no output in the debugger. Xcode organizer log is below.
2. Instead of using the SelectPerson event I decided to use my own ABPeoplePickerNavigationControllerDelegate delegate.
At first I was a little confused until I read the apple docs, that I had to override 3 functions in order for my subclassing to actually do anything.
public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson, int propertyId, int identifier)
Console.WriteLine ("USER SELECTED1");
public override bool ShouldContinue(ABPeoplePickerNavigationController peoplePicker, IntPtr selectedPerson)
Console.WriteLine ("USER SELECTED2");
public override void Cancelled(ABPeoplePickerNavigationController peoplePicker)
peoplePicker.DismissViewController (true, null);
This delegate (instead of the event) will allow me to select the user who would normally crash the app, but it won't do anything. I found this (http://stackoverflow.com/questions/6979846/how-to-get-abperson-from-an-intptr-using-monotouch) which says I should use some reflection in order to get this to work.
I added the following linq code.
ABPerson person = peoplePicker.AddressBook.SingleOrDefault(s => s.Handle == selectedPerson) as ABPerson;
Using the first function would be if I wanted to use a specific user detail, using the 2 parameter function will allow me to use the detail of the user as a whole.
Anyway, this single line of linq will work fine and select a normal user who would normally not crash the app, whereas this line will cause the app to crash on a specific entry as discussed earlier.
Commenting out the line will then work.
This is not an issue with person being null or anything, it literally wont execute past this function.
Throwing a try/catch block around it does not change anything. :|
Below is my pastebin dump of the xcode organizer console output of my device and the crash log it generated.
Is the SelectPerson event a MonoTouch specific thing, and its doing a similar call on its internals and thats why it is also crashing?
Not sure where else to go from here...
Also, I am using XamarinStudio 4.0.1 (build 9) and Xamarin.iOS 184.108.40.206 (Business Edition). Tested on my iPhone 5 (iOS 6.1.2).
Are you using any kind of crash reporting (TestFlight, etc)?
It looks like it's a null reference exception (see frame 7 in thread 1), but that shouldn't crash the app (and in particular not in a different thread).
I am indeed using TestFlight.
With it disabled, I get "Object reference not set to an instance of an object" printed to my XS console when I tried to select that user.
I went back to using the original event everything worked fine and was something later in my code which was to blame.
foreach (ABMultiValueEntry<string> phone in phones)
string phoneLabel = phone.Label.ToString();
// Other things, but phone.Label was null here.
So I guess TestFlight was catching errors for me... but that did not make sense as a Console.WriteLine above this was not outputting anything.
Sometimes I've seen crashes preventing Console.WriteLines immediately before getting printed - it seems iOS caches output sometimes and if the app crashes the output is lost.
Here is how to make TestFlight and NullReferenceExceptions play nice together: http://stackoverflow.com/questions/14499334/how-to-prevent-ios-crash-reporters-from-crashing-monotouch-apps
Thanks so much for the help. Am glad its not a bug in MT :)