UWP Desktop App Activation of Release builds (x64/x86) from visual studio 2022 fails

DotNET Fan 46 Reputation points
2023-01-06T12:12:51.653+00:00

When running the release version of the UWP App build from Visual studio 2022 , get the below activation error.

Unable to activate Windows Store app ''xxxxxx". The activation request failed with error 'Operation not supported. Unknown error: 0x80040904'.

The debug builds are working fine.

Development environment:

OS - Microsoft windows 11 Home - 10.0.2262 Build 22621
Visual studio version: 17.4.2 64 bit

UWP App - Target version Windows 11 , version 22H2 (10.0 Build 22621)
Min version - Windows 10 version 1903 (10.0 Build 18362)

Project Build setting:

<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>

<Use64BitCompiler>true</Use64BitCompiler>

I have created a sample test UWP app and the release build works from visual studio 2022.

The troubleshooting steps mentioned in the microsoft website is to look at the event viewer and could not trace the actual reasons for this error.

The eventviewer logs from Applications and Services Logs/Microsoft/Windows/Apps/Microsoft-Windows-TWinUI/Operational section-

Activation for XXXX!App failed. Error code: Unknown HResult Error code: 0x80040904. Activation phase: COM App activation

Data Name="ErrorCode">-2147219196</Data>
<Data Name="PhaseFlags">33</Data>

Microsoft UWP experts , could you please let me know the reasons and any further troubleshooting steps for this?

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. DotNET Fan 46 Reputation points
    2023-01-19T08:32:09.0633333+00:00

    I have managed to figure out the reason for this issue. Hope this helps anyone facing this issue as this has taken more time to identify the root cause than the fix and it is happening only in release mode. The fix is a very small change and I strongly feel that UWP framework release mode error reporting should have been much better and developer friendly.

    The issue is due to an extra forward slash in the path while reading the resource dictionary, crazy

    The code that breaks in release mode

    <ResourceDictionary Source="ms-appx:///CustomApp.Views//styles/CommandrStyles.xaml" />

    Removing extra slash before styles path worked.

    <ResourceDictionary Source="ms-appx:///CustomApp.Views/styles/CommandrStyles.xaml" />

    No comments