Issues with RequestPurchaseAsync in MFC C++ Application

Ming Yu 0 Reputation points
2024-10-17T17:29:05.5766667+00:00

An app has been published in the Partner Center, and an addon submission has been created. This is the addon subscription overview.

User's image

In the application, there is an MFC project and a Windows Runtime Component (Universal Windows) project, as depicted below.

User's image

The Class1 is declared as follows:

namespace WindowsRuntimeComponent1
{
    public ref class Class1 sealed
    {
    public:
        Class1();
        int Purchase();
    };
}

The method Purchase() is implemented as:

int Class1::Purchase()
{
    Windows::Services::Store::StoreContext^ storeContext;
    storeContext = StoreContext::GetDefault();    

    create_task(storeContext->RequestPurchaseAsync("myAddonStoreID")).then([](StorePurchaseResult^ result)
    {
        // .......
    }, task_continuation_context::get_current_winrt_context());
}

The program crashes at the line:

create_task(storeContext->RequestPurchaseAsync("myAddonStoreID")).then([](StorePurchaseResult^ result)

What mistakes could be causing this issue? Thank you very much.

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,743 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
340 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.