1. ishaan_666's Avatar
    I'm trying to share an image through my app, everything works just fine when I run the app on my phone through visual studio, but when I try to run it from my phone, it crashes everytime I click the share button.

    private async void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    {
    args.Request.Data.Properties.Title = "Let's Celebrate";
    args.Request.Data.Properties.Description = "It's time to celebrate!";
    DataRequestDeferral deferral = args.Request.GetDeferral();
    try
    {
    var finalImg = await GenerateImage();

    var folder = Package.Current.InstalledLocation;
    const CreationCollisionOption option = CreationCollisionOption.ReplaceExisting;
    var file = await folder.CreateFileAsync("letscelebrateshare.png", option);
    var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi;
    var pixelBuffer = await finalImg.GetPixelsAsync();

    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
    {
    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
    encoder.SetPixelData(
    BitmapPixelFormat.Bgra8,
    BitmapAlphaMode.Premultiplied,
    (uint)finalImg.PixelWidth,
    (uint)finalImg.PixelHeight,
    logicalDpi,
    logicalDpi,
    pixelBuffer.ToArray());

    await encoder.FlushAsync();

    StorageFile logoFile =
    await Package.Current.InstalledLocation.GetFileAsync("letscelebrateshare.png");
    List<IStorageItem> storageItems = new List<IStorageItem>();
    storageItems.Add(logoFile);
    args.Request.Data.SetStorageItems(storageItems);
    }
    }
    finally
    {
    deferral.Complete();
    }

    }
    Help please?
    07-08-2014 02:22 PM
  2. Nerdy Woman's Avatar
    I'm trying to share an image through my app, everything works just fine when I run the app on my phone through visual studio, but when I try to run it from my phone, it crashes everytime I click the share button.



    Help please?
    Ishaan, I am not a dev, but I appreciate the frustration when something doesn't work the way it should. You might also try posting in the Windows Dev Community.

    https://dev.windowsphone.com/en-us/community

    If you feel more comfortable communicating in another language, there is a language selection button at the very bottom of the page.
    07-08-2014 08:22 PM
  3. Catholic Tech Geek's Avatar
    I see a try statement with a finally, but not a catch. Try catching a (general) Exception object and print out the error. If it's not going to bottleneck things, try showing a MessageDialog with the error. Visual Studio will tell you you you can't await an async function in a catch clause, but you can get around that by calling the async function as a task and get it's awaiter

    Catch(Exception ex) {
    MessageDialog dlg = new MessageDialog("the error was: " + ex.message);
    dlg.ShowAsync().AsTask().GetAwaiter();
    }
    07-12-2014 12:21 PM

Similar Threads

  1. Gmail "Send Mail As" alias issue with WP8.1
    By azerrima in forum Windows Phone 8.1
    Replies: 5
    Last Post: 07-20-2014, 04:26 AM
  2. Replies: 7
    Last Post: 07-12-2014, 06:02 AM
  3. When Will WP update with Cortana be available
    By Jerry Tovar in forum Cortana
    Replies: 1
    Last Post: 07-08-2014, 02:09 PM
  4. Linked In issue
    By WPCentral Question in forum Ask a Question
    Replies: 0
    Last Post: 07-08-2014, 10:00 AM
  5. Internet Explorer issue (tabs)
    By Quinn FitzGerald in forum Windows Phone 8.1 Preview for Developers
    Replies: 2
    Last Post: 07-08-2014, 08:12 AM
LINK TO POST COPIED TO CLIPBOARD