Home > Software design >  WinUI3 Microsoft.UI.XAML.dll "Source Code Not Available" error on Debug
WinUI3 Microsoft.UI.XAML.dll "Source Code Not Available" error on Debug

Time:12-07

My app builds fine. Attempting to start it in debug mode, however, causes this error. This appeared after I solved an error relating to missing "debug symbols" Screenshot of Source Not Available error

This post seems to suggest the issue was using WPF - but I am not using WPF. I also see a potentially similar issue here, but there appear to be no answers.

I am not sure where to even begin fixing this - it seems to be a Visual Studio issue or a project/solution config issue rather than a code issue. Any ideas?

CodePudding user response:

I fixed it. I was looking at the output in the Visual Studio Console (after stopping the app once the error mentioned in the question happened), and I saw this:

Exception thrown at 0x00007FFD41D4466C (KernelBase.dll) in EmailClient.exe: WinRT originate error - 0x80004005 : 'WinUI: Error creating second Desktop Window on the current process. No more than one Desktop Window is allowed per process.'. onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFD43EAA21E: (caller: 00007FFD43D9A2F3) ReturnHr(2) tid(5e98) 8007007E The specified module could not be found.

I then searched through my project, and found out I was calling new MainWindow() one place in my project outside of the App.xaml.cs when initializing a property. I removed that (initializing the property to null instead), and now the app works fine. Not sure how the two are related... but this may be an unexpected behavior caused by attempting to create multiple windows on the same process. Here is someone else who had the same issue.

If your intention is to create multiple windows (mine was not) and you want to know how, then see this thread (a few months out-of-date... not sure if the mentioned features are still in preview or not as of time of posting).

  • Related