We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

A first chance exception of type 'System.FormatException' occurred in Syncfusion.SfPdfViewer.WinRT.DLL

Thread ID:





117739 Dec 5,2014 09:07 AM UTC Dec 8,2014 11:49 AM UTC WinRT 1
Tags: SfPdfViewer
Ric Silva
Asked On December 5, 2014 09:07 AM UTC

Im getting this exception:
"A first chance exception of type 'System.FormatException' occurred in Syncfusion.SfPdfViewer.WinRT.DLL"

it happens when im in my main page, and press a tile that navigates to a new page that opens a pdf then go back to main page, and press tile again to open the same pdf
it doesn't allways happen, but when it does, its when i try to open the pdf a second time.

in my pdf page i have this section

public PdfPage()
            //NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled; 
            this.DataContext = this;

        protected override async void OnNavigatedTo(NavigationEventArgs e)
            //DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
            backButton.IsEnabled = false;
            backButton.Visibility = Visibility.Collapsed;
            document = e.Parameter as Document;

            if (document.Source == SourceType.Join)
                pdfTrace.Visibility = Visibility.Collapsed;
                pdfShare.Visibility = Visibility.Collapsed;


            var error = false;

                await GetFile();

                await Task.Delay(2000);
                //await SetFileTraces("open", document.GetFullPath());
                backButton.IsEnabled = true;
                backButton.Visibility = Visibility.Visible;

            catch (FileNotFoundException e1)
                Debug.WriteLine("pdfpage.cs 87    " + e1.Message);
                error = true;
            catch (Exception e1)
                Debug.WriteLine("PDFpage.cs  90 " + e1.Message);
                ShowMessageDialog("Connection Lost!");

            if (error)
                await new MessageDialog("The file does not exist!", "Error").ShowAsync();


        private async Task GetFile()
                backButton.IsEnabled = false;
                //IsLoading = true;

                var path = document.GetFullPath();
                byte[] bytes = null;

                if (document.Source == Enums.SourceType.Join)
                    JoinService joinService = new JoinService();
                    string nameNoExt = document.Name.Remove(document.Name.Length - 4, 4);
                    string handle = document.Handle;
                    bytes = await joinService.GetFileAsync(handle);
                    bytes = await gappService.GetFileAsync(path);


                pdfDocument = new PdfLoadedDocument(bytes);
                pdfViewer.DocumentLoaded += (sender, e) =>
                        pdfViewer.ViewMode = PageViewMode.FitWidth;
                    catch (Exception e1)
                        Debug.WriteLine("pdfpage.cs 128    " + e1.Message);

                backButton.IsEnabled = true;
            catch (Exception e)
                Debug.WriteLine("PDFPage   175  " + e.Message);


in my output window i get

"A first chance exception of type 'System.FormatException' occurred in Syncfusion.SfPdfViewer.WinRT.DLL
pdfpage.cs 128    Input string was not in a correct format."

in the exception stacktrace i have this

   "at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Syncfusion.Windows.PdfViewer.PdfDocumentView.IncludeCanvas(Int32 pageIndex, Int32 width, Int32 height)
   at Syncfusion.Windows.PdfViewer.PdfDocumentView.<LoadPages>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__4(Object state)
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()"

and my exception message is: ""Value does not fall within the expected range." and sometimes {"Value does not fall within the expected range."}

im using Syncfusion 8.1 Controls for WinRT XAML version

Uthistran S [Syncfusion]
Replied On December 8, 2014 11:49 AM UTC

Hi Ric,

Thank you for your update.

We are unable to reproduce the issue of "A first chance exception of type 'System.FormatException' occurred in Syncfusion.SfPdfViewer.WinRT.DLL". Please find the sample in the link below with which we tried to reproduce the issue, please modify this sample or provide us a simple sample with which this issue could be reproduced. This will help us to further investigate on this.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/PDFViewerWintRT_20131105639088.zip

Please, let us know if you need any further assistance.


Uthistran S.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon