StoreContext.GetAppLicenseAsync() returns false for active subscription in MSIX CLI

M McKanstry 0 Reputation points
2025-06-12T16:21:17.58+00:00

I'm building a WinRT CLI wrapper in C# that checks if a user owns an active Microsoft Store subscription add-on. This CLI is called from an Electron + React.js app using command-line arguments and returns true or false depending on the license status.

The Problem

The CheckSubscription <AddonId> command incorrectly returns false, even though the logged-in user does have an active subscription to the add-on.

I ran the application within these conditions:

  • MSIX-packaged CLI app (Windows 10+)
  • Published to Microsoft Store (delisted for testing)
  • Using StoreContext.GetAppLicenseAsync()
  • Subscription add-on is published and testable
  • The add-on ID resolves correctly via the API

I have also confirmed that my app does indeed receive a list of addons that a user has a liscence to sometimes.


Below is the Code Snippet


private static async Task HandleCheckSubscriptionCommand(string[] args)
{
    string addonId = args[1];
    var context = StoreContext.GetDefault();
    var license = await context.GetAppLicenseAsync();
    foreach (var kvp in license.AddOnLicenses)
    {
        var addOnLicense = kvp.Value;
        if (addOnLicense.SkuStoreId.Equals(addonId, StringComparison.OrdinalIgnoreCase))
        {
            bool isValid = addOnLicense.IsActive && addOnLicense.ExpirationDate > DateTimeOffset.UtcNow;
            Console.WriteLine(isValid ? "true" : "false");
            return;
        }
    }
    Console.WriteLine("false");
}

What can I do to resolve this issue?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,561 questions
0 comments No comments
{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.