locked
LicenseInfo gives unhandled exception when the app is not in the store yet

    Question

  • It seems I don't quite understand how LicenseInfo works. Everywhere in the samples where it's used it has the

    #define USE_STORE_SIMULATOR 1

    for supposed debug builds. But if I uncomment that I get a nasty exception which doesn't point me to anything. Or rather if someone knows what

            __throwInfo    0x53aee53c {vccorlib110d.dll!__TI10P$AAVCOMException@Platform@@}    void *

    means, that would be great (this is __throwinfo from winRTException object from the thrown exception during some ListingInformation task).

    Now my problem is as follows. If I compile this on release, it still crashes. I made the store app package and although I tested the app thoroughly and it works flawlessly adding the license info part crashes it. My app has failed review because of a crash and I suspect this is it. If I manually install the app package I submitted for review... it still crashes.

    I also have a different app I submitted that I wanted to add the licenseinfo part. This one DOESN'T CRASH when I add the LicenseInfo. I assume it searches for the app listing on the store or something but on the first release there isn't anything on the store so... it isn't possible to release an app with licensing information (as in to sell it) on the first release of an app ?

    Tuesday, January 22, 2013 11:28 PM

Answers

  • UPDATE :

    Ok, I found the magical formula. The problem was fixed by this complete code :

    void App::InitializeLicenseCore()
    {
            task<ListingInformation^> listingTask(CurrentApp::LoadListingInformationAsync());        

            listingTask.then([=](ListingInformation^ listing)
            {
            }).then([](task<void> t)
            {
                try    
                {
                    t.get();
                    // .get() didn't throw, so we succeeded.
                    OutputDebugString(L"ListingInformation loaded.");
                }
                catch (Platform::Exception^ e)
                {
                    OutputDebugString(e->Message->Data());
                }
            });

    }

            


    However I was having an overencompassing try/catch from my initial try (right at the beginning of the function). If you have any other try/catch blocks including this one it will fail. Too bad the sample didn't came with this source code already.



    Friday, January 25, 2013 5:08 AM

All replies

  • Hi Ciprian,

    Please see the sticky post Passing Store Certification

    As discussed there, the CurrentApp class will raise an exception if it cannot connect to the store servers, either because the app isn't yet in the store or because lack of network connectivity. Apps which use CurrentApp need to handle this exception.

    If you need more specific help then please provide exact details of what your code is doing, the steps needed to reproduce the problem, and the specific results you get.

    --Rob

    Wednesday, January 23, 2013 12:00 AM
    Owner

  • Ok, so first off, I had code from this sample : http://code.msdn.microsoft.com/windowsapps/Metro-style-DirectX-18f98448 which has a lot of licensing code in it but does not handle exceptions when the LoadListingInformationAsync function is called. This is the first call that gets a crash. I added the try/catch, but it still crashes without any caught exception.

    The most basic form is this :

    try   {      task<ListingInformation^> listingTask(CurrentApp::LoadListingInformationAsync());          listingTask.wait();

    }  catch(Platform::Exception ^ e)   {

    //        breakpoint never gets hit }


    I even tried adding wait but it doesn't change anything.

    Now that I think of it though, I should call try on the thread that is throwing the exception but since it's an async call and I don't really know what thread it is being called on, I can't really get the try correctly. I don't know what microsoft did there, but it looks faulty to me.

    Thursday, January 24, 2013 2:05 AM
  • Hi Ciprian,

    Your try/catch block will only catch the exceptions thrown in that actual function. It won't catch errors thrown within the Task, since that will run outside the scope of the try/catch block.

    Instead chain the tasks and then wrap the final task.get() call in a try/catch block to catch exceptions raised along the task chain:

    task<ListingInformation^> listingTask(CurrentApp::LoadListingInformationAsync()); 
    
    listingTask.then([](task<void> t) 
        {
            try
            {
                t.get();
                // .get() didn't throw, so we succeeded.
                OutputDebugString(L"ListingInformation loaded.");
            }
            catch (Platform::Exception^ e)
            {
                OutputDebugString(e->Message->Data());
            }
        });
    

    See Asynchronous programming in C++ (Windows Store apps) for more details.

    --Rob

    • Proposed as answer by Jesse Jiang Friday, January 25, 2013 3:03 AM
    Thursday, January 24, 2013 2:30 AM
    Owner
  • UPDATE :

    Ok, I found the magical formula. The problem was fixed by this complete code :

    void App::InitializeLicenseCore()
    {
            task<ListingInformation^> listingTask(CurrentApp::LoadListingInformationAsync());        

            listingTask.then([=](ListingInformation^ listing)
            {
            }).then([](task<void> t)
            {
                try    
                {
                    t.get();
                    // .get() didn't throw, so we succeeded.
                    OutputDebugString(L"ListingInformation loaded.");
                }
                catch (Platform::Exception^ e)
                {
                    OutputDebugString(e->Message->Data());
                }
            });

    }

            


    However I was having an overencompassing try/catch from my initial try (right at the beginning of the function). If you have any other try/catch blocks including this one it will fail. Too bad the sample didn't came with this source code already.



    Friday, January 25, 2013 5:08 AM
  • I solved the previous problem but now it seems that if you call the purchase task from a different thread other than the main thread, it gives an unhandled exception (sometimes it says it's access denied) that I cannot catch even with the magic trick above.

    I'm basically doing

    if (BuyFullVersion) {         if ((m_licenseInformation != nullptr) && m_licenseInformation->IsActive)         {             if (m_licenseInformation->IsTrial)         {                 task<Platform::String^> purchaseTask(CurrentApp::RequestAppPurchaseAsync(false));                 purchaseTask.then([=](Platform::String^ Str)             {                 //Inside purchase task

       }).then([]( task<void> t )                 {                     try         {                        t.get();                     }                     catch (Platform::Exception^ exception)                  {                         if (exception->HResult == E_FAIL)                         {                                                     }                     }                 });             }             else            {                 // "You already have the full version!"     

           }        }     }

    The same issue is found if say you make a task in which you make a message box and display it. Some internals just want certain calls to be made from the main thread. It's kind of weird given that many functions are called Async in the first place.


    Sunday, January 27, 2013 7:40 AM