locked
Photo App is not sharing the file to the share target? RRS feed

  • Question

  • Hi,

    I have created a C# Windows 8.1 store app with Share Target declaration for the following file types TIFF, JPEG, PNG etc., After deployment, I have tried to share some images(tiff/jpg/png) from Photos app. But I am not able to receive the file the getfileasync() is failed and catched exception. Please let me know is it the default behavior or bug because I have read some information from the below link: http://gcoupe.wordpress.com/2013/07/03/windows-8-1-photo-app/

    Regards

    Ashok

    Friday, November 15, 2013 1:25 PM

All replies

  • I'm not on a dev system and cant test this myself, but can you successfully share to the share target sample? My first test whenever I have sharing problems os to compare the behavior in the share target and source samples and examine what data is actually available.

    --Rob

    Friday, November 15, 2013 3:59 PM
    Moderator
  • Pretty sure this is the identical question I asked 2 months ago, and reposted just a few days ago. We are days from shipping and cannot get sharing to work reliably from either the Photos or Skydrive app due to the same issue...

    This is easy to repro, just follow the instructions for modifying that share target sample in my post...

    http://social.msdn.microsoft.com/Forums/en-US/43c82539-e1ed-45c4-9284-8d12eaacf47c/avoiding-crashes-when-handling-files-during-a-share-target-sequence?forum=wingameswithdirectx

    FreshPaint handles it fine so they figured it out, please enlighten the rest of us so all the apps can play nice together the way win8 was conceived.  Also, the facebook app was working fine sharing until they posted an update on the 14th, now it does not share with any app. Ugh!! The Twitter app fails to share with anyone, and de-authenticates your account and logs you out.



    Saturday, November 16, 2013 2:20 PM
  • I see this same behavior with the Photos app as a Share Source. Here's the simplest repro I can think of.

    App.xaml.cs:

    using Windows.ApplicationModel.Activation;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    
    namespace App1
    {
    	sealed partial class App : Application
    	{
    		public App()
    		{
    			this.InitializeComponent();
    		}
    
    		protected override void OnLaunched(LaunchActivatedEventArgs e)
    		{
    			var frame = new Frame();
    			Window.Current.Content = frame;
    			frame.Navigate(typeof(MainPage));
    			Window.Current.Activate(); 
    		}
    
    		protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
    		{
    			var frame = new Frame();
    			Window.Current.Content = frame;
    			frame.Navigate(typeof(SharePage), args.ShareOperation);
    			Window.Current.Activate(); 
    		}
    	}
    }


    SharePage.xaml

    <Page
        x:Class="App1.SharePage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    </Page>


    SharePage.xaml.cs

    using System;
    using Windows.ApplicationModel.DataTransfer.ShareTarget;
    using Windows.Storage;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Navigation;
    
    namespace App1
    {
    	public sealed partial class SharePage : Page
    	{
    		public SharePage()
    		{
    			this.InitializeComponent();
    		}
    
    		protected async override void OnNavigatedTo(NavigationEventArgs e)
    		{
    			var op = (ShareOperation)e.Parameter;
    
    			var items = await op.Data.GetStorageItemsAsync();
    
    			var file = (StorageFile)items[0];
    
    			var stream = await file.OpenReadAsync(); // this line causes the crash
    		}
    	}
    }
    


    Package.appxmanifest

    <?xml version="1.0" encoding="utf-8"?>
    <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
      <Identity Name="45c9b9f7-c6d5-41cb-b40a-7a512041b153" Publisher="CN=Mark" Version="1.0.0.0" />
      <Properties>
        <DisplayName>App1</DisplayName>
        <PublisherDisplayName>Mark</PublisherDisplayName>
        <Logo>Assets\StoreLogo.png</Logo>
      </Properties>
      <Prerequisites>
        <OSMinVersion>6.3.0</OSMinVersion>
        <OSMaxVersionTested>6.3.0</OSMaxVersionTested>
      </Prerequisites>
      <Resources>
        <Resource Language="x-generate" />
      </Resources>
      <Applications>
        <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="App1.App">
          <m2:VisualElements DisplayName="App1" Square150x150Logo="Assets\Logo.png" Square30x30Logo="Assets\SmallLogo.png" Description="App1" ForegroundText="light" BackgroundColor="#464646">
            <m2:SplashScreen Image="Assets\SplashScreen.png" />
          </m2:VisualElements>
          <Extensions>
            <Extension Category="windows.shareTarget">
              <ShareTarget>
                <SupportedFileTypes>
                  <SupportsAnyFileType />
                </SupportedFileTypes>
              </ShareTarget>
            </Extension>
          </Extensions>
        </Application>
      </Applications>
      <Capabilities>
        <Capability Name="internetClient" />
      </Capabilities>
    </Package>

    If I run the target app under the debugger, use Photos as the Share Source, then I get this exception:

    {"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.\r\n\r\nA COM call (IID: {33EE3134-1DD6-4E3A-8067-D1C162E8642B}, method index: 6) to an ASTA (thread 5684) was blocked because the call chain originated in or passed through another ASTA (thread 12492). This call pattern is deadlock-prone and disallowed by apartment call control."}

    If I write my own Share Source, it works fine, no exception:

        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
    
    			DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested;
            }
    
    		async void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    		{
    			var deferral = args.Request.GetDeferral();
    
    			var file = await KnownFolders.PicturesLibrary.GetFileAsync("Star.jpg");
    
    			var items = new List<IStorageItem>();
    			items.Add(file);
    
    			args.Request.Data.Properties.Title = "MyTitle";
    			args.Request.Data.SetStorageItems(items);
    
    			deferral.Complete();
    		}
        }
    
    Any thoughts appreciated, I never programmed COM so it is hard for me to decode that error message. Thanks!
    Thursday, May 1, 2014 2:13 AM