Search code examples
c#windows-store-appsin-app-purchasewin-universal-appwindows-8.1-universal

ReloadSimulatorAsync produces "Value does not fall within the expected range" exception


In my Universal Windows App I test iap purchases. I've done this before in another app, and it worked. Have no idea why it doesn't work this time. Here's the code:

    StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
    StorageFile proxyFile = await proxyDataFolder.GetFileAsync("WindowsStoreProxy.xml");
    CurApp.LicenseInformation.LicenseChanged += () => Log("License info changed");
    await Windows.ApplicationModel.Store.CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);

And ReloadSimulatorAsync produces "Value does not fall within the expected range" exception! Suppose it's something to do with xml parsing, but of course, file exists and has the right format:

<?xml version="1.0" encoding="utf-16" ?>
<CurrentApp>
  <ListingInformation>
    <App>
      <AppId>[my app id]</AppId>
      <LinkUri>https://www.microsoft.com/store/apps/[my app store code]</LinkUri>
      <CurrentMarket>en-US</CurrentMarket>
      <AgeRating>7</AgeRating>
      <MarketData xml:lang="en-us">
        <Name>MyTestApp</Name>
        <Description>AppDescription</Description>
        <Price>0.0</Price>
        <CurrencySymbol>$</CurrencySymbol>
      </MarketData>
    </App>
    <Product ProductId="product2" LicenseDuration="0" ProductType="Durable">
      <MarketData xml:lang="en-us">
        <Name>Durable1</Name>
        <Price>0.99</Price>
        <CurrencySymbol>$</CurrencySymbol>
      </MarketData>
    </Product>
    <Product ProductId="amnt1" LicenseDuration="0" ProductType="Consumable">
      <MarketData xml:lang="en-us">
        <Name>Consumable1</Name>
        <Price>0.99</Price>
        <CurrencySymbol>$</CurrencySymbol>
      </MarketData>
    </Product>
  </ListingInformation>
  <LicenseInformation>
    <App>
      <IsActive>true</IsActive>
      <IsTrial>false</IsTrial>
    </App>
    <Product ProductId="product2">
      <IsActive>true</IsActive>
    </Product>
  </LicenseInformation>
  <ConsumableInformation>
    <Product ProductId="amnt1" TransactionId="00000001-0000-0000-0000-000000000000" Status="Active"/>
  </ConsumableInformation>
</CurrentApp>

Why could this happen?


Solution

  • I can reproduce your issue if I use the XML you provided, because AppId may be not correct, here you may need to give GUID. You can replace the [my app id] with 988b90e4-5d4d-4dea-99d0-e423e414ffbc Microsoft provided and try it again.

    More detailed information about XML you can refer to in-app purchase.

    I also find Store sample(demonstrates trials and in-app purchase) you can refer to.

    Here is my XML:

    <?xml version="1.0" encoding="utf-16" ?>
     <CurrentApp>
      <ListingInformation>
    <App>
      <AppId>988b90e4-5d4d-4dea-99d0-e423e414ffbc</AppId>
      <LinkUri>http://apps.microsoft.com/webpdp/app/988b90e4-5d4d-4dea-99d0-e423e414ffbc</LinkUri>
      <CurrentMarket>en-us</CurrentMarket>
      <AgeRating>3</AgeRating>
      <MarketData xml:lang="en-us">
        <Name>In-app purchases</Name>
        <Description>AppDescription</Description>
        <Price>5.99</Price>
        <CurrencySymbol>$</CurrencySymbol>
        <CurrencyCode>USD</CurrencyCode>
      </MarketData>
    </App>
    <Product ProductId="product1">
      <MarketData xml:lang="en-us">
        <Name>Product 1</Name>
        <Price>1.99</Price>
        <CurrencySymbol>$</CurrencySymbol>
        <CurrencyCode>USD</CurrencyCode>
      </MarketData>
    </Product>
    <Product ProductId="product2">
      <MarketData xml:lang="en-us">
        <Name>Product 2</Name>
        <Price>2.99</Price>
        <CurrencySymbol>$</CurrencySymbol>
        <CurrencyCode>USD</CurrencyCode>
      </MarketData>
    </Product>
       </ListingInformation>
     <LicenseInformation>
    <App>
      <IsActive>true</IsActive>
      <IsTrial>false</IsTrial>
    </App>
    <Product ProductId="product1">
      <IsActive>true</IsActive>
    </Product>
    <Product ProductId="product2">
      <IsActive>false</IsActive>
       </Product>
    </LicenseInformation>
     </CurrentApp>