获取此异常的地址: “Syncfusion.SfPdfViewer.WinRT.DLL中发生类型'System.FormatException'的第一个机会异常“在一个Windows商店应用程序项目中。Syncfusion.SfPdfViewer.WinRT.DLL中发生类型'System.FormatException'的第一个机会异常
它发生在我的主页中,然后按导航到一个新的页面,打开一个PDF然后回到主页面,并再次按瓷砖打开相同的pdf 它不会发生,但是当它发生时,它会在第二次尝试打开PDF时出现。
在我的PDF页面我有这个节
public PdfPage()
{
this.InitializeComponent();
//NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
this.DataContext = this;
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(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;
try
{
await GetFile();
//DispatcherTimerSetup();
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!");
Frame.Navigate(typeof(LoginPage));
}
if (error)
{
await new MessageDialog("The file does not exist!", "Error").ShowAsync();
Frame.GoBack();
}
}
private async Task GetFile()
{
try
{
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);
Debug.WriteLine("JOIN");
}
else
{
bytes = await gappService.GetFileAsync(path);
}
pdfDocument = new PdfLoadedDocument(bytes);
pdfViewer.DocumentLoaded += (sender, e) =>
{
try
{
pdfViewer.ViewMode = PageViewMode.FitWidth;
}
catch (Exception e1)
{
Debug.WriteLine("pdfpage.cs 128 " + e1.Message);
}
};
pdfViewer.LoadDocument(pdfDocument);
backButton.IsEnabled = true;
}
catch (Exception e)
{
Debug.WriteLine("PDFPage 175 " + e.Message);
}
}
在我的输出窗口,我得到
“类型‘System.FormatException’的第一次机会异常出现在Syncfusion.SfPdfViewer.WinRT.DLL pdfpage.cs 128输入字符串格式不正确。“
在异常堆栈跟踪我有这个
“
完在System.ThrowHelper.ThrowArgumentException(ExceptionResource 资源)在System.Collections.Generic.Dictionary
2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary
2.增加(TKEY的关键,TValue值)
在Syncfusion.Windows.PdfViewer.PdfDocumentView.IncludeCanvas(的Int32 的PageIndex,的Int32宽度,高度的Int32)在 Syncfusion.Windows.PdfViewer.PdfDocumentView.d__54.MoveNext() ---从先前位置)堆栈跟踪其中例外在 System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore(抛出---在 System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__4(对象 状态)
“
和我的异常消息为:‘’使用Syncfusion 8.1控制为值不在所述预期范围内”,有时{“值没有在预期范围内。”}
IM。 WinRT XAML版本12.2.0.36 (它也是ap当我在模拟器中测试时会发生更多次的梨)