UWP app fails to start on login using the StartupTask APIs

2

NOTE: I've already looked at this related question, this is not a duplicate

I'm working on a UWP app which also uses the Desktop Bridge (the app package contains the UWP app and a WinForms component), and I'm trying to add the auto startup feature, so far without success.

Here's what I did:

  • Some research. Looked at this question mentioned before, this blog post from MS and at the official docs as well.

  • Followed the docs by editing the Package.appxmanifest file to add the uap5 namespace, and then the uap5:Extension node as instructed, setting my app .exe file in the Executable property, and Windows.FullTrustApplication in the EntryPoint property.

  • Bonus: just in case, I also tried to replace the uap5 namespace with desktop, as some code samples used that one instead. Same result, the app doesn't start at all.
  • Included the APIs to get the startup task and request it to be setup.
  • Deployed the app, proceeded to use those APIs, got the confirm window and tapped "allow".
  • Opened the Task Managed and double checked that the app name was there under the "Startup" tab, with the "Enabled" label correctly shown next to it.
  • Logged out and back in

At this point nothing happens, except from the mouse pointer showing the loading ring for half a second after logging in. Opened the Windows event viewer and found an error, which was indicating the failed auto startup for the app. Tried again a few times and sure enough, every time the app didn't start and another identical error popped up in the event viewer. This is the error info:

Application name: <my app>.exe, versione: 1.0.0.0, timestamp: 0x5a68410c
Module: KERNELBASE.dll, versione: 10.0.17134.407, timestamp: 0x99042cc0
Exception code: 0xe0434352
Offset: 0x000000000003a388
Process ID: 0x1c4c
Path: C:\Users\<my username>\Documents\GitHub\<my app>\<my app>.Package\bin\x64\Debug\AppX\<my app>.exe
Module path: C:\Windows\System32\KERNELBASE.dll
[...]

I'm not sure what I'm doing wrong here, I've followed the docs step by step and I do see the app listed in the Task Manager, but it just fails to start this way.

Any help would be appreciated, thanks in advance! 😄

EDIT: it seems the problem is related to the Desktop Bridge functionality. I have a UWP app and a packaging project, and I've added the startup task to both the .appxmanifest files (with different Ids). I do this as I use the packaging project to create the x86/x64 builds, and the UWP project directly for the ARM/ARM64 builds.

If I only deploy the UWP app (standalone, without the package) and enable the startup task, the app runs fine. But, if I deploy the packaging project and enable that startup task, the startup fails. I do see the startup task in the Task Manager in both cases. As mentioned earlier, when the startup task fails for the packaging project, I see those errors in the event viewer.

EDIT #2: did some more tests with the Desktop Bridge app. It seems that after it fails to start, the Windows event logger gets two more errors listed there for each attempt. One is the error in the "Application Error" category mentioned earlier, and another one is an error in the "AppModel-Runtime" category, with the following info:

Failed with 0x490 modifying AppModel Runtime status for package for user (current status = 0x0, desired status = 0x20).

EDIT #3: as requested, here's the .appxmanifest file for the packaging project. Note that as mentioned earlier, I tried adding the startup task both using the desktop namespace as well as the newer uap5 namespace. Again, in both cases I can retrieve the task and prompt the user to enable it, and I do see it listed in the Task Manager, but the application still fails to start with the usual error.

c#
uwp
windows-10-universal
desktop-bridge
windows-10-desktop
asked on Stack Overflow Nov 16, 2018 by Sergio0694 • edited Nov 19, 2018 by Sergio0694

1 Answer

1

When setting up a StartupTask extension in your appxmanifest it is important to understand that the declaration is different for Win32 components vs UWP components. This is documented here: https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.StartupTask

UWP Components:

<Package xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" ...>
...
<Applications>
    <Application ...>
        ...
        <Extensions>
          <uap5:Extension Category="windows.startupTask">
            <uap5:StartupTask
              TaskId="MyStartupId"
              Enabled="false"
              DisplayName="Test startup" />
          </uap5:Extension>
      </Extensions>
    </Application>
</Applications>

Win32 Components:

<Package xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"...>
...
<Applications>
    <Application ...>
        ...
        <Extensions>
          <uap5:Extension
            Category="windows.startupTask"
            Executable="MyDesktopBridgeApp.exe"
            EntryPoint="Windows.FullTrustApplication">
            <uap5:StartupTask
              TaskId="MyStartupId"
              Enabled="false"
              DisplayName="My Desktop Bridge App" />
          </uap5:Extension>
        </Extensions>
    </Application>
</Applications>
answered on Stack Overflow Nov 19, 2018 by Stefan Wick MSFT

User contributions licensed under CC BY-SA 3.0