WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

ToastNotification run as admin will exception

Open YiChunLin105062518 opened this issue 11 months ago • 4 comments

Describe the bug

In the standard user account, run app as admin, the app execution identity will be admin, resulting access is denied when prompt notification.

Regression

No response

Reproducible in sample app?

  • [X] This bug can be reproduced in the sample app.

Steps to reproduce

1.loggin standard user account
2.run app as admin
3.the app call show toast:
new ToastContentBuilder()
.AddText(title)
.AddText(mag)
.Show();
4.toast not show and thrown exception:
[Exception in LogUnhandledException] exception: System.UnauthorizedAccessException: Access is denied. (0x80070005 (E_ACCESSDENIED))
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
   at ABI.Windows.UI.Notifications.IToastNotifierMethods.Show(IObjectReference _obj, ToastNotification notification)
   at Windows.UI.Notifications.ToastNotifier.Show(ToastNotification notification)
   at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.Show(ToastNotification notification)
   at Microsoft.Toolkit.Uwp.Notifications.ToastContentBuilder.Show(CustomizeToast customize)
   at XXX.ToastHandler.<>c_DisplayClass11_0.<ShowToast>b_0()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Expected behavior

notification to be prompted under the standard user account.

Screenshots

No response

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

Windows 11 (22H2)

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

Microsoft Visual Studio Professional 2022 (64 bit) - Current version 17.5.4

Device form factor

Desktop

Nuget packages

Microsoft.Toolkit.Uwp.Notifications 7.1.2, 7.1.3

Additional context

No response

Help us help you

No.

YiChunLin105062518 avatar Jul 28 '23 08:07 YiChunLin105062518