0

在我的通用Windows应用程序中测试iap购买。我之前已经在另一个应用中完成了这个工作,并且它工作。不知道为什么这次不行。 下面的代码:ReloadSimulatorAsync产生“值不在预期范围内”异常

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); 

而且ReloadSimulatorAsync产生“值没有在预期范围内”例外!假设它的东西做XML解析,当然,文件存在并具有正确的格式:

<?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> 

为什么会这样呢?

回答

1

如果我使用您提供的XML,我可以重现您的问题,因为AppId可能不正确,在这里您可能需要提供GUID。您可以将[我的应用程序ID]988b90e4-5d4d-4dea-99d0-e423e414ffbc Microsoft提供并再次尝试。

有关XML的更多详细信息,请参阅in-app purchase

我也找到Store sample(demonstrates trials and in-app purchase)你可以参考。

这里是我的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> 
+0

谢谢!但我在哪里可以找到指导?在应用程序的详细信息上,我只能看到姓氏和市场与数字字母索引的链接,但它不是一个guid。 – Tertium

+0

啊,刚刚发现 - 你可以使用任何guid进行测试。当我到达计算机 – Tertium

+0

与随机guid它终于工作将检查它。我认为它使用了遗留代码(windows phone 7+),当你不得不使用guid而不是家族id时,需要guid。 – Tertium

相关问题