C++/WinRT background task (non UWP)

JafarM 1 Reputation point
2022-04-07T00:28:59.643+00:00

Hi, I'm looking to create a win32 app utilizing WinRT to use UWP Background Task

I tried to find some samples on the internet and I found two main "official" repos

here
https://github.com/microsoft/Windows-universal-samples/tree/main/Samples/BackgroundTask/cpp

and here
https://github.com/microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/BackgroundTaskWinMainComSample/CppWinRT

I also found this
https://social.msdn.microsoft.com/Forums/en-US/1ecb28ea-c8fa-484c-a400-3f6e689eca6c/uwpcwinrt-background-task-sample?forum=wpdevelop

but in the end this is seems to be a starter point and later the samples were published under this
https://github.com/microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/BackgroundTaskWinMainComSample/CppWinRT

And the formal doc for it is this
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-a-winmain-background-task

My initial goal was to create a Win32 app that loads a WinRT component / library (load the .winmd file).
This works well and I can use WinRT "space" from win32 and use all the available apis.

Next I wanted to create a background task based on the interface.
Found the samples, they work for UWP but are crashing on me for C++/WinRT and COM samples above.

I've ran them on three different machines, same result. I must be doing something wrong or something is missing.

Next, I've tried to not use COM and try to use the code to run from the C++/WinRT component I have created,
and the same thing happened, it crashes on me.

In this case I know that the manifest manifest file also plays an important role, but I don't know the correct format it has to be in as for other projects the XML starts with "Package" for the win32 migrated project is starts with "assembly"

For example crashes and the xml see the attached pictures.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,649 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,755 questions
{count} votes

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.