Winforms .exe in MSIX Package Does Not Startup After Auto Update

Brass Contributor

We are deploying a classic Winforms .exe via MISX. Approximately 20% of the time, the application does not start automatically after an auto update completes. After an update and failed start, we can trigger the application to startup by just typing random text into the Windows search bar. Another way we can trigger it to start is to re-launch the application via the start menu item, but of course two instances will then be running. 

 

 

 

We are testing with 5 separate workstations that have Windows 10 1903. I have logging in the Main method of the application in program.cs, so I can see that nothing attempts to execute after the auto update until the user intervenes. This has lead me to believe that there is nothing in the application itself causing the issue, but rather the MSIX framework or a configuration option. 

 

The appinstaller file -

 

 

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller Uri="{AppInstallerUri}"
              Version="{Version}"
              xmlns="<a href="<a href="<a href="http://schemas.microsoft.com/appx/appinstaller/2018" target="_blank">http://schemas.microsoft.com/appx/appinstaller/2018</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/appinstaller/2018</a" target="_blank">http://schemas.microsoft.com/appx/appinstaller/2018</a</a>>" target="_blank"><a href="<a href="http://schemas.microsoft.com/appx/appinstaller/2018</a" target="_blank">http://schemas.microsoft.com/appx/appinstaller/2018</a</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/appinstaller/2018</a</a" target="_blank">http://schemas.microsoft.com/appx/appinstaller/2018</a</a</a>>>">
  <MainBundle Name="{Name}"
              Version="{Version}"
              Publisher="{Publisher}"
              Uri="{MainPackageUri}"/>
  <UpdateSettings>
    <OnLaunch HoursBetweenUpdateChecks="0" ShowPrompt="true" UpdateBlocksActivation="true"/>
    <AutomaticBackgroundTask/>
    <ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>
  </UpdateSettings>
</AppInstaller>

 

 

 
The appxmanifest -

 

 

 
<?xml version="1.0" encoding="utf-8"?>
<Package
  xmlns="<a href="<a href="<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a</a>>" target="_blank"><a href="<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10</a</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a</a</a>>>"
  xmlns:uap="<a href="<a href="<a href="http://schemas.microsoft.com/appx/manifest/uap/windows10" target="_blank">http://schemas.microsoft.com/appx/manifest/uap/windows10</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/uap/windows10</a" target="_blank">http://schemas.microsoft.com/appx/manifest/uap/windows10</a</a>>" target="_blank"><a href="<a href="http://schemas.microsoft.com/appx/manifest/uap/windows10</a" target="_blank">http://schemas.microsoft.com/appx/manifest/uap/windows10</a</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/uap/windows10</a</a" target="_blank">http://schemas.microsoft.com/appx/manifest/uap/windows10</a</a</a>>>"
  xmlns:rescap="<a href="<a href="<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a</a>>" target="_blank"><a href="<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a</a>" target="_blank"><a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a</a" target="_blank">http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities</a</a</a>>>"
  IgnorableNamespaces="uap rescap">
  <Identity
    Name="IMSPolicy.local"
    Publisher="CN=Foo, O=Foo, L=MyTown, S=MyState, C=US"
    Version="1.0.14.0" />
  <Properties>
    <DisplayName>MyApp</DisplayName>
    <PublisherDisplayName>FooPublisher</PublisherDisplayName>
    <Logo>Images\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate"/>
  </Resources>
  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="$targetentrypoint$">
      <uap:VisualElements
        DisplayName="MyApp Dev"
        Description="MyApp application package"
        BackgroundColor="transparent"
        Square150x150Logo="Images\Square150x150Logo.png"
        Square44x44Logo="Images\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png"  Square71x71Logo="Images\SmallTile.png" Square310x310Logo="Images\LargeTile.png"/>
        <uap:SplashScreen Image="Images\SplashScreen.png"  BackgroundColor="white"/>
      </uap:VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
    <rescap:Capability Name="runFullTrust" />
  </Capabilities>
</Package>

 

 

46 Replies

@ChreesM 

 

A few questions:

 

  1. To make sure I understand what's going on, are you launching the app, the update UI pops up, installs the update successfully and at the end of the update the app doesn't launch?
  2. Can you please share:

C:\Users\<UserName>\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\AILog.txt from when this issue occurs.

 

And just to make sure, can you please check Task Manager to see if your app's process is present when the issue occurs.

 

Thanks

Tanaka

@Tanaka_Jimha 

1. Yes, that is correct.

 

2. attached

 

3. The application's process does not appear in Task Manager during a hang.

@ChreesM 

 

Thanks for the info. We're looking into the issue, I'll keep you posted.

 

Tanaka

@Tanaka_Jimha  - Hi Tanaka,

 

Just checking in to see if there has been any movement on this item.

 

Regards

Hi @ChreesM,

 

I don't have an update from the dev team yet. I'll let you know once I do. Some folks are out for Thanksgiving this week.

 

Cheers,

Tanaka

Hi @ChreesM 

 

Unfortunately our devs weren't able to reproduce the issue and the logs aren’t showing anything so we don't have anything to use for debugging right now.

 

Are you able to reproduce the issue on one of your machines currently? I understand it can be hard since you said it only happens 20% of the time. Our best bet to get to the bottom of it now is for you to file a Feedback Hub bug while the issue is occurring -, this will collect a lot more logs & traces and help us investigate. If you can reproduce the error, can please try capture it using Feedback Hub:

Launch Feedback Hub

Category -> Problem -> Install & Update -> App installation issues

Make new bug

Important functionality not working

Recreate My Problem -> Start Recording

Try reproduce the issue

Stop recording

Submit

 

Thanks!

Tanaka

@Tanaka_Jimha- We have been able to reproduce the error on multiple machines about every 5th update, as long as there is a legitimate code change versus just incrementing the version number. We were not successful reproducing the error when there is not a real code change involved.

 

We will attempt to capture with Feedback Hub. Do you want me to post the results to this thread? 

@ChreesM 

 

Yes please update the thread when you've managed to capture via Feedback Hub.

 

Thanks,

Tanaka

@Tanaka_Jimha- We captured the issue today with Feedback Hub. Files attached as requested.

Thank you @ChreesM! I'll forward this to our dev team to investigate.

 

Thanks again,

Tanaka

@Tanaka_Jimha- We have been doing some more internal testing/investigation of this issue. We setup a fresh VM with Windows 10 (build 1909), and made sure there isn't any antivirus software, group policy, etc. We are still experiencing the issue. We did note an error in the Appx log, although ultimately the deployment was successful, we just had to jumpstart the process.

 

Event Viewer – Administrative Events

Error      1/14/2020 6:27:00 AM  AppModel-Runtime        69           None

Failed with 0x490 modifying AppModel Runtime status for package IMSPolicy.Test_3.0.20014.1_neutral__jth0c9f684k02 for user CARPENTERD-TEST\DeleteMe (current status = 0x0, desired status = 0x20).

 

Log Name:      Microsoft-Windows-AppModel-Runtime/Admin

Source:        Microsoft-Windows-AppModel-Runtime

Date:          1/14/2020 6:27:00 AM

Event ID:      69

Task Category: None

Level:         Error

Keywords:      Process

User:          SYSTEM

Computer:      carpenterd-test.svmic.com

Description:

Failed with 0x490 modifying AppModel Runtime status for package IMSPolicy.Test_3.0.20014.1_neutral__jth0c9f684k02 for user CARPENTERD-TEST\DeleteMe (current status = 0x0, desired status = 0x20).

 

Event Xml:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

  <System>

    <Provider Name="Microsoft-Windows-AppModel-Runtime" Guid="{f1ef270a-0d32-4352-ba52-dbab41e1d859}" />

    <EventID>69</EventID>

    <Version>0</Version>

    <Level>2</Level>

    <Task>0</Task>

    <Opcode>0</Opcode>

    <Keywords>0x2000000000000001</Keywords>

    <TimeCreated SystemTime="2020-01-14T14:27:00.545054900Z" />

    <EventRecordID>900</EventRecordID>

    <Correlation ActivityID="{766f81f1-cae6-0000-3798-6f76e6cad501}" />

    <Execution ProcessID="4416" ThreadID="4564" />

    <Channel>Microsoft-Windows-AppModel-Runtime/Admin</Channel>

    <Computer>carpenterd-test.svmic.com</Computer>

    <Security UserID="S-1-5-18" />

  </System>

  <EventData>

    <Data Name="ErrorCode">1168</Data>

    <Data Name="PackageFullName">IMSPolicy.Test_3.0.20014.1_neutral__jth0c9f684k02</Data>

    <Data Name="User">S-1-5-21-4057247019-2708646856-1072159069-1001</Data>

    <Data Name="DesiredStatus">32</Data>

    <Data Name="CurrentStatus">0</Data>

  </EventData>

</Event>

@ChreesM 

 

Thanks for the new logs and update. I've forwarded them to the dev team and followed up with you more info.

 

Tanaka

@Tanaka_Jimha Has there been any word on the progress of this item? Our company has a winforms application that is deployed as MSIX and I noticed this morning that it fails to automatically launch after the update process.  I'm testing on Windows 10 21H1

 

However, Touching the start menu button after about 20 seconds seems to bring it up.  I've enclosed the AILog.txt that shows the update was successful. I will also try to run the Feedback Hub application the next time there's an update.   Thank you for your time.

Hi @John_Cote,

 

I will be reaching out to the team today to see if there has been any updates on this for you. I'll update you once I hear more.

 

Thank you,

Roy

@Roy_MacLachlan   Jumping into the chain we are also having this same exact issue sporadically.  Any updates on a fix?

@Roy_MacLachlan We have the same problem with our WPF apps.

@ChreesM I can repro this 100 % of the time with my own MSIX app, just by pointing the .appinstaller file to a different version.
I have found out that the app actually launches, right when the dialog closes, but it becomes a Background process - only visible in the Task Manager.

I believe this is why it is sometimes possible to awaken it by clicking the Start button, searching and so on.


My workaround to this bug is to disable the app from being able to run as a background process at all. Go to Settings -> Background apps to do this.

The dialog closes but the user has to start the app manually. This is also a usability issue because the user is not told they have to start it manually.

I believe this sounds very similar to the problem I'm experiencing here with the so-called "gap" time:

https://techcommunity.microsoft.com/t5/msix-deployment/what-is-the-quot-gap-quot-and-how-do-i-elimin...

The symptoms I see are identical to what you guys are seeing. The app will appear, but it needs to be prodded along or sometimes it just appears by itself.

A bit more info:

 

  1. I got Windows into a state where I could reproduce this 100% of the time. The AppInstaller XML used was below.
  2. The AI log showed no problems, which isn't a surprise as the bug seems to be in the start/taskbar code.
  3. I didn't see my app EXE in task manager, not as a background task or anything else, and disabling background tasks makes no difference.
  4. Although I thought this was related to the "gap" in the AppxDeploymentServer logs, I can reproduce this also without any large values in the gap timings.
  5. In fact there is no timing issue involved here, even though it seemed that way at first. Careful testing shows that in my case, the app will never start until the start menu or search bar is interacted with, at which point it starts immediately. Interacting with other parts of the taskbar doesn't trigger this. It doesn't matter how long I wait after an upgrade - if I don't touch search or start button, the app will not launch after an upgrade.
  6. If I open the start menu I don't have to re-launch my app from there or do anything else. The mere act of clicking on it will cause the app to launch, and in fact, when it does it will steal focus and thus the start menu will disappear again.
  7. However after changing my AppInstaller XML to disable the prompt, doing a couple of upgrades, and then changing it back the problem has gone away. Now Windows starts the app after an upgrade successfully. To me this smells like another caching bug: perhaps Windows isn't handling changes to the OnLaunch settings properly and the taskbar/AppInstaller components can get confused about what update modes the app is meant to be using?

XML:

 

<OnLaunch HoursBetweenUpdateChecks="0" ShowPrompt="true" UpdateBlocksActivation="true"/>
<AutomaticBackgroundTask />
<ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>

 

I noticed from reading the documentation that the way App Installer is invoked doesn't seem very deeply integrated with Windows. Supposedly the upgrade check is done only if the taskbar is used to launch the app. If you have e.g. a shortcut on your desktop, and use that, then App Installer doesn't get involved at all. Or if any other process starts your app, same thing, the update check isn't done.

 

Therefore what seems to be happening is something like this:

 

  • The taskbar/start menu code is asked to launch an app controlled by AppInstaller.
  • It consults its timeout list and notices it's time to do an update check.
  • It passes control to App Installer to do the update and waits for a signal that the update has been completed.
  • AI sends that signal (somehow).
  • Something goes wrong: the Start code has been put to sleep in a way that it doesn't wake up when the signal arrives.
  • Interacting with the taskbar in such a way that the list of app icons is pulled up, re-awakens that part of the code, which then notices the signal from App Installer and continues with the launch of the app.

This doesn't happen on every code path. If an update check is done but no update is required, the launch works OK (but that might be a timing-caused red herring?).

 

A workaround is to disable the prompt using ShowPrompt="false" and go to fully silent upgrades i.e. with background upgrades only. This means that if an update has just been released and the user starts their app, it will be the old version and the next start will be upgraded, but, this is only a short window of time as after 8 hours Windows will (supposedly) apply the upgrade in the background anyway. Fully silent upgrades are what Chrome uses so this is an acceptable workaround for now - it is only an issue if the app needs to be forcibly upgraded to match e.g. a protocol change on a server.

 

In that case the app itself may need to figure out by itself if it's fully up to date or not and if not, restart itself to re-load the updated code - possibly monitoring the AppX logs to figure out when Windows has finished applying the upgrade.