ReloadSimulatorAsync 产生 "Value does not fall within the expected range" 异常
ReloadSimulatorAsync produces "Value does not fall within the expected range" exception
在我的通用 Windows 应用程序中,我测试了 iap 购买。我之前在另一个应用程序中做过这个,并且它有效。不知道为什么这次不起作用。
这是代码:
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 产生 "Value does not fall within the expected range" 异常!假设它与 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>
为什么会这样?
如果我使用你提供的XML我可以重现你的问题,因为AppId可能不正确,这里你可能需要给GUID。你可以把[my app id]换成微软提供的988b90e4-5d4d-4dea-99d0-e423e414ffbc再试试
更多关于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>
在我的通用 Windows 应用程序中,我测试了 iap 购买。我之前在另一个应用程序中做过这个,并且它有效。不知道为什么这次不起作用。 这是代码:
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 产生 "Value does not fall within the expected range" 异常!假设它与 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>
为什么会这样?
如果我使用你提供的XML我可以重现你的问题,因为AppId可能不正确,这里你可能需要给GUID。你可以把[my app id]换成微软提供的988b90e4-5d4d-4dea-99d0-e423e414ffbc再试试
更多关于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>