Is CurrentAppSimulator.RequestProductPurchaseAsync for WinUI 3 apps

Hong 1,436 Reputation points
2025-12-07T21:52:39.93+00:00
StorageFile file = await Package.Current.InstalledLocation.GetFileAsync("Data\\WindowsStoreProxy.xml");
await CurrentAppSimulator.ReloadSimulatorAsync(file);
ListingInformation ListingInfo = await CurrentAppSimulator.LoadListingInformationAsync();
PurchaseResults resultSimulatoin = await CurrentAppSimulator.RequestProductPurchaseAsync("my_product_token");

I checked ListingInfoin the above code. It looks correct - the product "my_product_token" is there.
However

CurrentAppSimulator.RequestProductPurchaseAsync("my_product_token")

Throws exception:

System.ArgumentException
  HResult=0x80070057
  Message=Value does not fall within the expected range.
  Source=WinRT.Runtime
  StackTrace:
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
   at ABI.Windows.ApplicationModel.Store.ICurrentAppSimulatorWithConsumablesMethods.RequestProductPurchaseAsync(IObjectReference _obj, String productId)
   at Windows.ApplicationModel.Store.CurrentAppSimulator.RequestProductPurchaseAsync(String productId)

Is CurrentAppSimulator.RequestProductPurchaseAsync supported for WinUI 3 apps?

Windows development | WinUI
0 comments No comments
{count} votes

Answer accepted by question author
  1. Raymond Huynh (WICLOUD CORPORATION) 3,955 Reputation points Microsoft External Staff Moderator
    2025-12-08T08:35:02.5066667+00:00

    Hello Hong,

    Thanks for the context. You’re using CurrentAppSimulator.RequestProductPurchaseAsync(...), which belongs to the Windows.ApplicationModel.Store simulator API. 

    https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.store.currentappsimulator.requestproductpurchaseasync?view=winrt-26100

    In some cases the simulation dialog does not appear and the call returns NotPurchased, even though the WindowsStoreProxy.xml seems to include the requested product. 

    Because of that, and because the store documentation itself suggests using the more modern Windows.Services.Store API for new or updated apps. I’d kindly suggest considering a migration. 

    https://learn.microsoft.com/en-us/windows/uwp/monetize/enable-in-app-product-purchases

    Switching to Windows.Services.Store can avoid subtle simulator issues, and help ensure your IAP logic works more reliably going forward.

    Hope this helps!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-07T21:53:49.42+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The CurrentAppSimulator.RequestProductPurchaseAsync method is part of the Windows.ApplicationModel.Store namespace, which is used for simulating in-app purchases in Windows applications. However, it is important to note that this method is primarily intended for use in Windows 8.1 and earlier versions. For applications targeting Windows 10 and later, including WinUI 3 apps, it is recommended to use the Windows.Services.Store namespace instead.

    The exception you are encountering, System.ArgumentException, suggests that there may be an issue with the parameters being passed or the state of the simulator. Ensure that the product ID you are using is correctly defined in your WindowsStoreProxy.xml file and that the simulator has been properly initialized with this file.

    If you are developing a WinUI 3 application, consider transitioning to the Windows.Services.Store namespace for handling in-app purchases, as it provides more robust support for modern Windows applications.


    References:

    0 comments No comments

Your answer

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