Search code examples
uwpxamarin.uwp

UWP App crash in release mode (faulting module: Windows.UI.Xaml.dll)


My UWP app crashes directly after startup in release mode with following error in event log:

Faulting application name: MyApp.exe, version: 1.0.0.0, time stamp: 0x6037ab09 Faulting module name: Windows.UI.Xaml.dll, version: 10.0.17763.1790, time stamp: 0x05b3601b Exception code: 0xc000027b

When I install a debug build, everything's fine.


Solution

  • I'm using Microsoft.Extensions.Logging and Microsoft.Extensions.Options in Version 5.00. It turns out the native compiler ist stripping out some parts which are needed at runtime.

    I found a description and a solution in this github issue: https://github.com/dotnet/runtime/issues/44697

    So I had to add all the assemblies to Default.rd.xml located under Properties:

    <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
        <Application>
            <Assembly Name="*Application*" Dynamic="Required All" />
            
            <!-- Add your application specific runtime directives here. -->
            <Assembly Dynamic="Required All" Name="Microsoft.Extensions.Options"/>
            <Assembly Dynamic="Required All" Name="Microsoft.Extensions.Logging"/>
            <Assembly Dynamic="Required All" Name="Microsoft.Extensions.Logging.Abstractions"/>
            <Assembly Dynamic="Required All" Name="Microsoft.Extensions.Hosting"/>
        </Application>
    </Directives>