question

dg2k avatar image
0 Votes"
dg2k asked WenyanZhang-MSFT commented

Sporadic System.Runtime.InteropServices.COMException while attempting to get WinUI AppWindow

I am using a widely used C# snippet (for instance here, also same code suggested as an answer to my earlier question) to get a WinUI AppWindow for setting start-up window dimensions.

Lately I'm getting System.Runtime.InteropServices.COMException (screenshot shown below), but strangely happens only about 1 in 4 or 5 times of launching the app.

I understand that this error may not be attributed to Maui (web search shows this error has been around for long) but posting it here just in case relevant because I only came across it while migrating to Maui. Event Viewer on Windows 11 (22H2 25158.1000) indicates:

Faulting module name: CoreMessagingXP.dll, version: 10.0.22621.1002, time stamp: 0xc93a5eeb

Visual Studio is Version 17.3.0 Preview 4.0

Is this a known issue with Maui and if so what is causing this?


222783-appwindowsexception.png


dotnet-maui
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi anonymous user-4673 , I created a .Net Maui template app, and tried to get the window. But I can't reproduce your issue, would you mind sharing the steps to reproduce? Is there any other method to use the window in your project? And may I ask your MAUI version?

0 Votes 0 ·
dg2k avatar image dg2k WenyanZhang-MSFT ·

Hi @WenyanZhang-MSFT.
The problem has now disappeared. I tried to reproduce by repeatedly launching and relaunching my Maui app that caused the exception and the app not misbehaving any more.

I didn't make anything significant to the app and the only notable change is rebooting my machine.

I will keep an eye if this problem shows up again, and update you by commenting here.
Thank you.

0 Votes 0 ·

OK. If you have any other issues, please feel free to let me know.

0 Votes 0 ·
Show more comments

1 Answer

dg2k avatar image
0 Votes"
dg2k answered

This issue never resurfaced, so I would assume it is not related to Maui which is good news.
I am just giving a closure to this question with this remark.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.