[UWP] Exception on start with Release mode

Bernd Seibold 26 Reputation points
2021-06-10T12:31:14.293+00:00

My UWP Xamarin Forms app crashes on startup ("Release-Mode") with the message:

Unhandled exception at 0x7650A6E2 (KernelBase.dll) in DineXamarin.UWP.exe: 0xE0434352 (parameters: 0x80070002, 0x00000000, 0x00000000, 0x00000000, 0x6C920000).

  • Im already using Xamarin.Forms.Forms.Init(e, assembliesToInclude); to register assemblies and it worked before.
  • Even if I rollback to a working version from the past it doesnt work anymore.
  • If I start Debug and with active .Net native toolchain for Debug it works

Using
Microsoft Visual Studio Community 2019Version 16.10.0
Windows 10 19042.985

Any ideas?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,369 questions
Universal Windows Platform (UWP)
{count} votes

9 answers

Sort by: Most helpful
  1. Store-Dev 1 Reputation point
    2021-08-21T21:10:00.613+00:00

    I have the same issue with a UWP app that does not use Xamarin. I also use SkiaSharp. Since Xamarin runs on top of UWP it could still be unrelated to SkiaSharp.

    I've tried rolling back to previous Nuget packages known to work -- all rollbacks were unsuccessful (some were not possible due to required code changes). Reinstallation and repair of multiple related components was also unsuccessful.

    Since the crash occurs before app code is even run there is no useful exception information. It is also not related to .NET native since it runs just fine in DEBUG mode with .NET native enabled. The only potentially useful message discovered is:

    CLR:(C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll) Rejecting native image because native image dependency C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expected
    CLR:(C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll) Rejecting native image because native image dependency C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had a different identity than expected

    I'm not sure how to correct this issue with mscorlib but an error loading it would definitely explain what we are seeing.

    0 comments No comments

  2. Dawson Bunn 1 Reputation point
    2021-08-26T14:48:13.883+00:00

    I too are having what could be the same problem.

    Had a UWP app in the MS store for over a year, just tried to do an updated after 4 months and DEBUG work fine, the RELEASE builds just crash on startup - Can't get any debugging going either!

    Unhandled exception at 0x765BB512 (KernelBase.dll) in {myApp}.exe: 0xE0434352 (parameters: 0x80070002, 0x00000000, 0x00000000, 0x00000000, 0x73C40000).

    Over the months I have updated VS2019 but I have tried to rollback some NuGet packages to but that does not help.

    Spent a day on this now :-(


  3. Bernd Seibold 26 Reputation points
    2021-08-29T19:04:48.113+00:00

    My solution was to create a VM to create the AppPackage/Release Build there. Not good but I have spent so much time and did not found a different solution

    0 comments No comments

  4. Alexey Vlasenko 1 Reputation point
    2021-09-18T21:56:27.66+00:00

    I got the same problem - the app released to Microsoft store failed to start when rebuilt in release mode. Debug build worked fine.
    Spent lots of time trying to fix it - clearing obj/Release folders, rolling back some Nuget packages, etc.

    Eventually I was able to make it work by removing *.user files. Credit to:
    https://github.com/xamarin/Xamarin.Forms/issues/12815#issuecomment-727003825

    Hope it'll help others.

    0 comments No comments

  5. Bernd Seibold 26 Reputation points
    2021-09-19T08:23:51.333+00:00

    Hi @Alexey Vlasenko ,
    thank you very much. This really helped. But its still hard to use. Here are my steps

    1. Clean everthing including user file obj/bin etc.
    2. Build in release
    3. Start the application on my local machine (with release). It works
    4. Create a app package for uploading to the windows store
    5. Start the application again on my local machine (with release) and its broken again!

    So how can be sure, that rhe app package is working? This is really frustrating

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.