我正在尝试应用程序购买应用程序接口(C++/CX),但RequestProductPurchaseAsync抛出了一个Platform::InvalidArgumentException^
我有以下代码:
// loading store
create_task(CurrentAppSimulator::LoadListingInformationAsync()).then([](ListingInformation^ listing)
{
auto product1 = listing->ProductListings->Lookup("product1");
auto product2 = listing->ProductListings->Lookup("product2");
});
//after that finishes I try to purchase product2
auto licenseInformation = CurrentAppSimulator::LicenseInformation;
if (!licenseInformation->ProductLicenses->Lookup("product2")->IsActive)
{
// this exact next line throws InvalidArgumentException
auto op = CurrentAppSimulator::RequestProductPurchaseAsync("product2", true); // throws !!!!!
auto purchaseTask = create_task(op);
purchaseTask.then([](task<Platform::String^> currentTask)
{
...
});
}
else ...如果在Windows应用商店示例项目中使用,则完全相同的代码可以工作,但在我自己的项目中不能工作。(显然使用相同的假冒产品xml文件)。
有没有人能看看?谢谢您:)
发布于 2013-02-01 01:00:59
我找到了解决方案:所有的WinRT存储函数都必须在UI线程上调用,所以从UI线程获取一个CoreDispatcher并保留它,以便通过它调用这些函数。
https://stackoverflow.com/questions/14185899
复制相似问题