I continued to research the issue and the original line of code mentioned above is not what acutally caused the crash. I kept commenting out blocks of code until I finally got things working in the Release build and then start adding back until it failed again.
Using the MemoryStream crashes in Release build but works in Debug build. It does the same thing. To answer your question about the reportPDFName it gets set based on the data record. I will give you the lines of code that lead up to it below. I can see that when in Debug mode, the pdf file does in fact get written out to the correct spot so I think that is working but it is below.
I do have a few varialbe running around like iSalvageId and sBaseFileName but those are just string values for overall path.
What is weird is that it works in debug mode so I assume all the paths are correct. And, I see zip files, jpg files and the xlsx file in there as well.
As for the XCode exception, I can post that below. I also use Test Flight and the crash report over on Test Flight said: monotouch_unhandled_exception_handler in monotouch-glue.m on Line 1436
I ran this on Android as I am create both apps android and iOS. Same thing happens on Android. It works in Debug mode but not in Release mode.
I was able to capture some application output for Android when it fails. Below is the output. It acts like it doesn't know the filename but I also ran the MemoryStream version and got the same error output.
MonoDroid] UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for FlexCel.Pdf.FormInput ---> System.NotSupportedException: CodePage 1252 not supported [MonoDroid] at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Pdf.FormInput..cctor () [0x00000] in <filename unknown>:0 [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at FlexCel.Pdf.PdfWriter.BeginDoc (System.IO.Stream aDataStream) [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay, Int32 startPageToExport, Int32 totalPagesToExport) [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay) [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Render.FlexCelPdfExport.ExportSheet () [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Render.FlexCelPdfExport.Export (System.IO.Stream pdfStream) [0x00000] in <filename unknown>:0 [MonoDroid] at FlexCel.Render.FlexCelPdfExport.Export (System.String fileName) [0x00000] in <filename unknown>:0 [mono] [mono] Unhandled Exception: [mono] System.TypeInitializationException: An exception was thrown by the type initializer for FlexCel.Pdf.FormInput ---> System.NotSupportedException: CodePage 1252 not supported [mono] at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0 [mono] at FlexCel.Pdf.FormInput..cctor () [0x00000] in <filename unknown>:0 [mono] --- End of inner exception stack trace --- [mono] at FlexCel.Pdf.PdfWriter.BeginDoc (System.IO.Stream aDataStream) [0x00000] in <filename unknown>:0 [mono] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay, Int32 startPageToExport, Int32 totalPagesToExport) [0x00000] in <filename unknown>:0 [mono] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay) [0x00000] in <filename unknown>:0 [mono] at FlexCel.Render.FlexCelPdfExport.ExportSheet () [0x00000] in <filename unknown>:0 [mono] at FlexCel.Render.FlexCelPdfExport.Export (System.IO.Stream pdfStream) [0x00000] in <filename unknown>: [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for FlexCel.Pdf.FormInput ---> System.NotSupportedException: CodePage 1252 not supported [mono-rt] at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0 [mono-rt] at FlexCel.Pdf.FormInput..cctor () [0x00000] in <filename unknown>:0 [mono-rt] --- End of inner exception stack trace --- [mono-rt] at FlexCel.Pdf.PdfWriter.BeginDoc (System.IO.Stream aDataStream) [0x00000] in <filename unknown>:0 [mono-rt] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay, Int32 startPageToExport, Int32 totalPagesToExport) [0x00000] in <filename unknown>:0 [mono-rt] at FlexCel.Render.FlexCelPdfExport.ExportSheet (Int32 startPageToDisplay, Int32 totalPagesToDisplay) [0x00000] in <filename unknown>:0 [mono-rt] at FlexCel.Render.FlexCelPdfExport.ExportSheet () [0x00000] in <filename unknown>:0 [mono-rt] at FlexCel.Render.FlexCelPdfExport.Export (System.IO.Stream pdfStream) [0x00000] in <filen
the issues in Android / iOS look like they might be different (even if not 100% sure).
In android, the problem seems clear:
CodePage 1252 not supported
While I am not 100% sure on how it is happening (FlexCel should detect the codepage doesn't exists), the simplest way to fix it would be to add that codepage support to your app. Go to the "Linker->Internationalization" settings, and make sure "west" is selected:
Also make sure you select "Release" in the box above so the settings are for release. This doesn't explain why it is working in Debug but not in Release, but it might give us a hint on what is happening.
After that, please try the same in iOS, the options are in "iOS Build->Advanced".
Note that there used to be a bug where Mono wouldn't catch the missing encoding, maybe somehow it came back:
If the codepage doesn't fix it, the other thing to try would be the linker. In the iOS side, the exception looks like it is when trying to get an aot, method, and it might be that it was removed form the linker.
And as in Debug the linker is set to "Don't link", this might be making a difference. Please try it without linker in the "iOS/Android" options (the "General" tab).
Thank you so much. That fixed it in both Android & iOS. I don't think I would have figured that one out. By selecting "west" in the "Release" options worked.
Thanks for letting me know. I'll investigate further, I might need to reopen the bug with Xamarin, since it shouldn't crash when "west" isn't selected.
But yes, "west" is needed in order to create pdfs.