Search code examples
windowsxamluwpuwp-xamlwinui

UWP App is crashing on startup but only after installing the app


I am having a problem with a UWP app that is crashing on startup. It crashes only once after the app is installed, either via Debug button on VS2019/2022 or via the Release bundle install package.

If I launch it a second time after the installation, the app won't crash anymore.

We don't know why that is going on and we would like to fix this crash so that the app doesn't crash after installing it.

The crash exception is the following:

Unhandled exception at 0x7726BF4B (MrmCoreR.dll) in AppName_UWP.exe: 0xC0000005: Access violation reading location 0x02000087.

I have uploaded an app memory dump as well as a screenshot showing everything that I have tried to fix this error until now - you can download it here

In a nutshell, we have tried:

  • Debugging in "Native Only"
  • Debugging in "Mixed"
  • Removing references to other libraries that could have caused the exception
  • Commenting references to Win UI
  • Change how XAML resources are added in App.xaml

Does anyone have an idea of what this could be and how to fix it?


Solution

    1. A teammate watched on App launch after installation in Process Monitor (by Sysinternals) and saw before App starting WerFault (preparing crash report) it is doing many stuff like "OverrideLanguagesList". enter image description here
    2. My teammate remembered that, in the app, we had code that was doing ApplicationLanguages.PrimaryLanguageOverride = stuff, and that when doing this app would be closed or restarted.
    3. My teammate searched for where we played with PrimaryLanguageOverride and saw indeed, during first launch it was overriden by some code, then during 2nd launch it is not overriden any more
    4. By analyzing with my teamate we saw that crash was generated because of how we handled language change in or BindableStrings class, we changed the responsible code as follows image
    5. Now app didn't crash anymore :)

    So main points:

    • You can use Process Monitor (by Sysinternals) to deeply analyze weird crashes in your Windows apps
    • Maybe this crash is related to some irresponsible code being present in some part of the app, most commonly tied to the resources of your app (strings localization, images, icons, etc...)