COMException -2147023728 when calling BackgroundTaskRegistration in MAUI WinUI project

ishebewhat 1 Reputation point
2025-01-17T01:50:11.8166667+00:00

I downloaded the C#/WinRT example here for implementing background tasks and it runs successfully, but it's a WPF app. Attempting to do the same in a single or multi-project MAUI app results in COMException -2147023728 when calling BackgroundTaskRegistration. In fact, I created both a brand new single and multi-app MAUI project, and added System.Diagnostics.Debug.WriteLine(Windows.ApplicationModel.Background.BackgroundTaskRegistration.AllTasks.Count); to the WinUI App constructor after InitializeComponent(); and it throws this exception. No other modifications. Just the new project and this line of code. I'm using VS 2022 on Windows 10 build 19045.5371.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,864 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 78,916 Reputation points Microsoft Vendor
    2025-01-21T08:51:08.0633333+00:00

    Hello,

    Since you mentioned the .NET version, I decided to try with a new .NET 8 project. It does work.

    Thanks for your update, you can use .NET 8.

    But not with .NET 9.

    Q&A is not a bug reporting site. Please report this issue in the MAUI GitHub repo.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.