title: UWP DataTransferManager ShowShareUI() Opens Sharing Dialog with "This app can't share right now" and Closes it Immediately After
body: <p>I am trying to share a file from my UWP app sandbox running on Windows 10 desktop.</p>
  
  <p>Following MS documentation on this page, the implementation seem to be fairly straight forward; however, I am having issues <a href="https://docs.microsoft.com/en-us/windows/uwp/app-to-app/share-data" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows/uwp/app-to-app/share-data</a></p>
  
  <p>I created DataTransferManager and attached DataRequested event in c-tor of my class as per explanation in the article:</p>
  
  <pre><code>DataTransferManager dataTransferManager;
  
  public MainPage()
  {
    this.InitializeComponent();
    ...
      dataTransferManager = DataTransferManager.GetForCurrentView(); 
      dataTransferManager.DataRequested += new TypedEventHandler&lt;DataTransferManager, DataRequestedEventArgs&gt;(this.OnDataRequested); 
  }
  </code></pre>
  
  <p>Next, in a method that is called from background thread, I call ShowShareUI making sure it executes on the main thread</p>
  
  <pre><code>Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt;
  {
      DataTransferManager.ShowShareUI(); //THIS CALL SHOWS A POPUP AND IMMEDIATELLY CLOSES IT
  }).AsTask().Wait();
  </code></pre>
  
  <p>Then in my OnDataRequested event, I add the file I want to share:</p>
  
  <pre><code>private async void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
  {
      // get the file from application sandbox
      StorageFile attachmentFile = await StorageFile.GetFileFromPathAsync(@"C:\Users\ME\AppData\Local\Packages\f040f23f-....-84\LocalState\logs\MYLOG.log");
      DataRequest request = args.Request; 
      request.Data.Properties.Title = "My Log File";
      request.Data.Properties.Description = "Sharing MYLOG file.";
      List&lt;IStorageItem&gt; storage = new List&lt;IStorageItem&gt;()
      {
          attachmentFile
      };
      request.Data.SetStorageItems(storage);
  }
  </code></pre>
  
  <p>but nothing happens.  I had no chance to select anything in the dialog that opened for a 1/2 second and closed.  Here is how the dialog looks like, it opens and closes almost immediately after it opened, it just show "This app can't share right now".</p>
  
  <p><a href="https://i.stack.imgur.com/iW3Q9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iW3Q9.png" alt="enter image description here"></a></p>