diff --git a/Dotnet/AppApi/AppApi.cs b/Dotnet/AppApi/AppApi.cs index 04aa098f..35962dca 100644 --- a/Dotnet/AppApi/AppApi.cs +++ b/Dotnet/AppApi/AppApi.cs @@ -242,18 +242,29 @@ namespace VRCX /// The optional image to display in the notification. public void DesktopNotification(string BoldText, string Text = "", string Image = "") { - ToastContentBuilder builder = new ToastContentBuilder(); - - if (Uri.TryCreate(Image, UriKind.Absolute, out Uri uri)) - builder.AddAppLogoOverride(uri); + try + { + ToastContentBuilder builder = new ToastContentBuilder(); - if (!string.IsNullOrEmpty(BoldText)) - builder.AddText(BoldText); - - if (!string.IsNullOrEmpty(Text)) - builder.AddText(Text); + if (Uri.TryCreate(Image, UriKind.Absolute, out Uri uri)) + builder.AddAppLogoOverride(uri); - builder.Show(); + if (!string.IsNullOrEmpty(BoldText)) + builder.AddText(BoldText); + + if (!string.IsNullOrEmpty(Text)) + builder.AddText(Text); + + builder.Show(); + } + catch (System.AccessViolationException ex) + { + logger.Warn(ex, "Unable to send desktop notification"); + } + catch (Exception ex) + { + logger.Error(ex, "Unknown error when sending desktop notification"); + } } ///