From f84007288bdcd3e27b518cf2b2d2cec9d369fbc0 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Wed, 27 Nov 2024 14:02:59 -0500 Subject: [PATCH] DYN-7531 Catch WebView2 initialization exception (#15685) --- .../Views/Core/DynamoView.xaml.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs index ebaddcaff2c..e779221cecc 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs @@ -1427,21 +1427,28 @@ private void LoadHomePage() { if (homePage == null && (startPage != null)) { - homePage = new UI.Views.HomePage(); - homePage.DataContext = startPage; - - var visibilityBinding = new System.Windows.Data.Binding + try { - RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DynamoView), 1), - Path = new PropertyPath("DataContext.ShowStartPage"), - Mode = BindingMode.OneWay, - Converter = new BooleanToVisibilityConverter(), - UpdateSourceTrigger = UpdateSourceTrigger.Explicit - }; + homePage = new UI.Views.HomePage(); + homePage.DataContext = startPage; + + var visibilityBinding = new System.Windows.Data.Binding + { + RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DynamoView), 1), + Path = new PropertyPath("DataContext.ShowStartPage"), + Mode = BindingMode.OneWay, + Converter = new BooleanToVisibilityConverter(), + UpdateSourceTrigger = UpdateSourceTrigger.Explicit + }; - BindingOperations.SetBinding(homePage, UIElement.VisibilityProperty, visibilityBinding); + BindingOperations.SetBinding(homePage, UIElement.VisibilityProperty, visibilityBinding); - this.newHomePageContainer.Children.Add(homePage); + this.newHomePageContainer.Children.Add(homePage); + } + catch (Exception ex) + { + Log(ex.Message); + } } }