OOP Background Task doesn't run in WinUI3/WinAppSDK desktop app when selfcontained and no dotnet installed #4115
Replies: 5 comments 41 replies
-
I found a reference to this error code in the dotnet/runtime github repository. It was in a file named host-error-codes.md. That doesn't mean that it is this CoreHostLibMissingFailure error though. |
Beta Was this translation helpful? Give feedback.
-
@DarranRowe I activated crash dump on the computer but no dump is being generated. I had 'taskbackgroundHost.exe' as key in the registry. Then started to look deeper in the Windows 10 computer and don't find any of the mentioned dotnet dlls (coreclr, hostfxr, hostpolicy) in there. Shouldn't a MSIX package install everything that is needed and/or complain when there are some core dlls missing. The strange thing is that the app itself (.NET6) runs without problems. Only OOP background tasks don't run. |
Beta Was this translation helpful? Give feedback.
-
Yes. The dotnet executable is part of the .NET (.NET core) runtime. This doesn't come pre-installed with any of the release versions of Windows. Visual Studio installs this and the .NET SDK when you install any of the .NET workloads. So it is not surprising for a developer system to have dotnet.exe but a non developer system to not have it.
This is a very much a no.
The WinUI 3 projects choose option 2, the .NET runtime is placed in the MSIX package. With how the packaging works, Windows should never end up with an incomplete package install either. There should be an integrity check for the files on install. So the interesting situation here is that if you take any .NET 5 or newer application (even without WinUI 3/Windows App SDK), package this up but do not publish it as self contained then the application will require a system installation of .NET to run. I suppose one other means of testing this situation is to have a machine with a clean Windows 10 install on it. Make sure to never install .NET or Visual Studio. Then sideload your package and try it out. Hopefully this should place you in the same situation. If it does fail in that situation, another test is to then install the .NET runtime that matches the application's .NET version on the system. If it then works, this would show that the background task engine in Windows isn't using the packaged version of .NET.
IIRC, .NET uses its own unhandled exception handler and this ignores the registry. Have you tried using the instructions here? |
Beta Was this translation helpful? Give feedback.
-
I have the same problem. My WinUI 3 application does not start any background task. I do not see any error or problem, but it does not work. |
Beta Was this translation helpful? Give feedback.
-
Hi @JosHuybrighs , sorry if that wasn't clear, "except for this problem" means that it doesn't work self contained. It's not a problem that the assemblies are in the same directory. If all the DLLs are in the same folder then the only reason I can think it wouldn't work is some manifest problem. Anyway, the point of this is that the original bug should be reactivated. If that's not possible then I can prepare a new sample project and post a new bug. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I have a beta version available of my WinUI3/WinAppSDK desktop app for a restricted set of users via Microsoft Store Package Flights. One of the users reports that none of the 4 background tasks in the app are executed. The 4 type of tasks are: a 15 minutes timer triggered task, a portable device watcher task, a session connect watcher task, and a package update task. All 4 are OOP BG tasks and run without issues on the other user's machines. The manifest file of course is correctly set up with the necessary entries:
And:
Event viewer on the user's computer gives the following error (in the BackgroundTaskInfrastructure section) for any of the 4 tasks when it tries to trigger them (next example is for the 'deviceUse' task, and translated from Dutch):
An instance of the background task with the access point SyncFolder.BackgroundTasks.PortableDeviceWatcherTask executed for the user ML\mlgoos in session 422859 was returned with error code 0x80008083.
Did also a test with enabling diagnostics in BackgroundTaskInfrastructure. These are the events being logged when a USB flashdrive is inserted (again translated from Dutch):
The fault occurs on Windows 10, build 19045.3930.
I looked around what 0x80008083 could mean but with no luck. Could it have something to do with OOP BG triggering and the WinRT.Host.dll that is part of the package? Wrong version?
I also checked on another Windows 10 machine with the same build but don't see any issue there. Must however say that on that machine I installed VS Remote tools for debugging. So there might be some packages installed that prevent that the error occurs.
The error occurs on the user's machine when installing from the Microsoft Store but also when sideloading the .msix package.
Any idea?
Steps to reproduce the bug
Register for participating in the beta test of the SyncFolder app and install SyncFolder from the Microsoft Store.
Expected behavior
No response
Screenshots
No response
NuGet package version
Windows App SDK 1.4.4: 1.4.231219000
Packaging type
Packaged (MSIX)
Windows version
Windows 10 version 22H2 (19045, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions