locked
I am having problems launch the default app for a PDF file

    Question

  • All,

    I am having problems launch the default app for a PDF file. The code below lets me launch a .png located in the Assets directory also, but it can’t lunch a PDF. I read through the below link and thought I understood what it was talking about but I must have missed something.

    http://msdn.microsoft.com/en-us/library/windows/apps/hh779671.aspx

    auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

           concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("Assets\\LSV Damage control manual.pdf"));

           getFileOperation.then([](Windows::Storage::StorageFile^ file)

           {

                  if (file != nullptr)

                  {

                         // Set the option to show the picker

                         auto launchOptions = ref new Windows::System::LauncherOptions();

                         launchOptions->DisplayApplicationPicker = true;

                         // Launch the retrieved file

                         concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file, launchOptions));

                         launchFileOperation.then([](bool success)

                         {

                               if (success)

                               {

                                      // File launched

                               }

                               else

                               {

                                      // File launch failed

                               }

                         });

                  }

                  else

                  {

                         // Could not find file

                  }

           });

    Below is the exception

    'Eular Layout.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.ApplicationModel.dll'. Cannot find or open the PDB file.

    First-chance exception at 0x75652EEC (KernelBase.dll) in Eular Layout.exe: 0x40080201: WinRT originate error (parameters: 0x80070002, 0x0000002C, 0x0562F1B0).

    Eular Layout.exe has triggered a breakpoint.

    Any ideas?

    Thanks,

    Grim

    Tuesday, February 18, 2014 6:50 PM

Answers

  • That's the same information as before and only tells us that there was an exception, not where it occurred or what the exception was. If you cannot debug this yourself can you provide a minimal sample that reproduces the problem?

    That it successfully works to launch a png suggests that the call itself is correct, but it doesn't tell us if we're getting to the call in the pdf case. I'd suggest breaking at the beginning of your function and stepping through to see where it actually fails. You can also put a breakpoint on the LaunchFileAsync call and see if you reach that breakpoint.

    With no actual data to back this up I'm guessing that you are getting a file not found error because the PDF file isn't included in your appx package. You can verify this by looking in the Appx directory to see if the PDF is there. If this is the case then you should be able to fix the problem by right clicking on the PDF file in the solution explorer, choosing properties, and then setting the Content property to yes.

    --Rob

    • Marked as answer by A.B.P.Lambert Tuesday, February 18, 2014 10:33 PM
    Tuesday, February 18, 2014 9:29 PM
    Moderator

All replies

  • Where does it fail? What is the exception (you snipped info that says there was one, but not the details of the exception itself)? From where is this code called (is it on the dispatcher thread?)

    Is it successfully finding the file? Is it getting to the call to LaunchFileAsync?

    The code isn't handling missing files correctly. That will raise an exception. See Asynchronous programming in C++ (Windows Store apps) for information on handling exceptions in async code.

    --Rob

    Tuesday, February 18, 2014 7:07 PM
    Moderator
  • I will look into Asynchronous. I was not sure what information to provide so I attached a .png file with a snap shot of what occurs when I try to launch the PDF file.

    Thanks for your help,

    Grim


    Tuesday, February 18, 2014 7:33 PM
  • Rob,

    It looks like the LaunchFileAsync is correct to perform the Asynchronous needed and since it is launch a .png file correctly there is something else happing.

    Thanks,

    Grim

    Tuesday, February 18, 2014 8:19 PM
  • That's the same information as before and only tells us that there was an exception, not where it occurred or what the exception was. If you cannot debug this yourself can you provide a minimal sample that reproduces the problem?

    That it successfully works to launch a png suggests that the call itself is correct, but it doesn't tell us if we're getting to the call in the pdf case. I'd suggest breaking at the beginning of your function and stepping through to see where it actually fails. You can also put a breakpoint on the LaunchFileAsync call and see if you reach that breakpoint.

    With no actual data to back this up I'm guessing that you are getting a file not found error because the PDF file isn't included in your appx package. You can verify this by looking in the Appx directory to see if the PDF is there. If this is the case then you should be able to fix the problem by right clicking on the PDF file in the solution explorer, choosing properties, and then setting the Content property to yes.

    --Rob

    • Marked as answer by A.B.P.Lambert Tuesday, February 18, 2014 10:33 PM
    Tuesday, February 18, 2014 9:29 PM
    Moderator
  • Rob,

    Thanks for your help. Why did I not have to do the same action to the .png file?

    Aric

    Tuesday, February 18, 2014 10:34 PM