locked
Avoiding crashes when handling files during a share target sequence..

    Question

  • So if we try to copy a file provided in a share sequence into a temp directory it works great with freshpaint, but crashes with the below debugger info if we share from the Photos app.  How does one code around this?  Freshpaint is able to share with the photo app so they must have this figured out.

    This is easy to repro by just adding the following code in the ShareTarget 8.1 C++ sample app in MainPage.xaml.cpp around line 259...

    then once you have this sharetarget running, launch photo or SkyDrive, then choose a photo then bring up the share charms and share with the sharetarget sample. This is all on win 8.1 with all the latest patches, using the released vis studio 2013.

    StorageFile^ theFile = dynamic_cast<StorageFile^> (sharedStorageItems->GetAt(i));

    create_task(theFile->CopyAsync(

    ApplicationData::Current->TemporaryFolder, theFile->Name,NameCollisionOption::GenerateUniqueName)).then([](task<StorageFile^> copiedTask){});

    .......

    First-chance exception at 0x76E43D67 in ShareTarget.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x074EC7A4. HRESULT:0x8000001F A COM call to an ASTA was blocked because the call chain originated in or passed through another ASTA. This call pattern is deadlock-prone and disallowed by apartment call control.

    WinRT information: A COM call (IID: {FA3F6186-4214-428C-A64C-14C9AC7315EA}, method index: 12) to an ASTA (thread 6880) was blocked because the call chain originated in or passed through another ASTA (thread 6184). This call pattern is deadlock-prone and disallowed by apartment call control.

    Stack trace:
    [External Code]
    ShareTarget.exe!SDKSample::ShareTarget::MainPage::OnNavigatedTo::__l115::<lambda>() Line 264
    [External Code]

    If there is a handler for this exception, the program may be safely continued


    Wednesday, November 13, 2013 10:34 PM

All replies

  • Hi SB,

    You didn't include the actual code snippet where you're adding that so I can't look at this until I get back to a dev machine during the week. I'll try to take a look when I'm back in the office.

    --Rob

    Saturday, November 16, 2013 3:44 PM
    Owner
  • That would be much appreciated... the snippet was just below...

    StorageFile^ theFile = dynamic_cast<StorageFile^> (sharedStorageItems->GetAt(i));
    
    create_task(theFile->CopyAsync(ApplicationData::Current->TemporaryFolder, theFile->Name,NameCollisionOption::GenerateUniqueName)).then([](task<StorageFile^> copiedTask){}); 

     
    Sunday, November 17, 2013 12:40 AM
  • Hi SB,

    Actually, I was asking about the context in which that snippet went. I don't have the samples memorized and had no idea what was around line 259.

    That said, I copied your snippet into the sample and ran it successfully. There was no crash, and the photo successfully copied to the temporary directory. There is a first chance exception, but it is handled so the app continues.

    --Rob

    Wednesday, November 20, 2013 2:00 AM
    Owner