So we upgraded to Xamarin Unified so our app – Project Tripod – would be accepted in to the store. It wasn’t a horrible process. Few refactors here and there. Of course, that meant we had to update Xamling-Core too. There were a few headaches there unfortunately.
We kept getting this strange crash when writing strings to the file system. It showed in a lot of our tests – ending with a crash something like this:
2015-01-24 12:35:23.660 AutomapperProblemReplicate[601:149248] critical: Stacktrace: 2015-01-24 12:35:23.661 AutomapperProblemReplicate[601:149248] critical: at 2015-01-24 12:35:23.661 AutomapperProblemReplicate[601:149248] critical: at (wrapper managed-to-native) object.__icall_wrapper_mono_array_new_specific (intptr,int) 2015-01-24 12:35:23.662 AutomapperProblemReplicate[601:149248] critical: at System.IO.StreamWriter.Initialize (System.Text.Encoding,int) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamWriter.cs:77 2015-01-24 12:35:23.662 AutomapperProblemReplicate[601:149248] critical: at System.IO.StreamWriter..ctor (string,bool,System.Text.Encoding,int) [0x00076] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/StreamWriter.cs:146
We spent quite some time debugging this… only to discover much later the culprit was something else entirely.
It was AutoMapper. Very strange indeed… remove all Mapper.CreateMap calls and Mapper.Map etc – and voila, problem gone.
We’ve raised an issue on the AutoMapper GitHub. It’s not been accepted or reviewed yet, so it’s not officially recognised, but maybe this post will help you anyway.