You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating my app AutoStartConfirm from .NET 8 to 9 and H.NotifyIcon.WinUI from 2.0.124 to 2.2.0, creating a new TaskbarIcon instance throws the following error:
System.Runtime.InteropServices.COMException
HResult=0x8001010E
Message=
Source=WinRT.Runtime
StackTrace:
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr) in WinRT\ExceptionHelpers.cs:line 134
at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr) in WinRT\ExceptionHelpers.cs:line 122
at ABI.Microsoft.UI.Xaml.IWindowMethods.get_Content(IObjectReference _obj)
at Microsoft.UI.Xaml.Window.get_Content()
at H.NotifyIcon.TaskbarIcon.<>c__DisplayClass25_0.<<PrepareContextMenuWindow>b__1>d.MoveNext()
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
While debugging I had a look at the failing code of this library and I noticed the following:
There is a line to delay code execution for 1 ms. Before this line window.Content is set, after the wait trying to access window.Content throws the mentioned exception.
There is no error message, but 0x8001010E usually means RPC_E_WRONG_THREAD. According to the Visual Studio thread window between these lines the executing thread switches from main to another Worker Thread ".NET TP Worker". Because access of GUI elements is only possible in the main thread, execution fails.
According to the documentation ConfigureAwait not guarantees continuation in the calling thread.
Maybe the await is a hack for previous versions that is not needed anymore and can be removed? If it is still needed, switching to something like Dispatcher.Invoke may be needed.
ChristianGalla
changed the title
COMException 0x8001010E thrown after .NET 9 update in PrepareContextMenuWindow
COMException 0x8001010E thrown in PrepareContextMenuWindow
Dec 30, 2024
Describe the bug
Hi,
nice project!
After updating my app AutoStartConfirm from .NET 8 to 9 and H.NotifyIcon.WinUI from 2.0.124 to 2.2.0, creating a new TaskbarIcon instance throws the following error:
While debugging I had a look at the failing code of this library and I noticed the following:
There is a line to delay code execution for 1 ms. Before this line window.Content is set, after the wait trying to access window.Content throws the mentioned exception.
There is no error message, but 0x8001010E usually means RPC_E_WRONG_THREAD. According to the Visual Studio thread window between these lines the executing thread switches from main to another Worker Thread ".NET TP Worker". Because access of GUI elements is only possible in the main thread, execution fails.
According to the documentation ConfigureAwait not guarantees continuation in the calling thread.
Maybe the await is a hack for previous versions that is not needed anymore and can be removed? If it is still needed, switching to something like Dispatcher.Invoke may be needed.
Steps to reproduce the bug
No response
Expected behavior
No error is thrown
Screenshots
No response
NuGet package version
Microsoft.WindowsAppSDK 1.6.241114003
H.NotifyIcon.WinUI 2.2.0
Platform
WinUI
IDE
Visual Studio 2022
Windows Version
Windows 10
WindowsAppSDK Version
Other
WindowsAppSDK Type
Unpackaged
Manifest
No response
Additional context
Maybe this is related to issue #175?
The text was updated successfully, but these errors were encountered: