Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to debug DataTransferManager? It works inside debugger and fails outside the debugger.

$
0
0


 I am adding a Share feature to a WPF app on Windows 10 based on the MSDN blog post here (Sharing Content from your Win32, WinForms or WPF App -- Nice post, Arun. Thanks!)  I downloaded the sample and got it to work after fixing up the path to the Windows.winmd file. It works both inside the debugger and out.

 

I integrated that sample into my WPF app and the Share feature works -- the share panel opens -- when I run my app inside Visual Studio 2015. But when I stop the debugger and run the exe directly from the File Explorer the share panel *does not open up*.  If I attach to the exe from Visual Studio then the panel opens. (!) How can I debug this?

 

I addedExtensive logging which reveals that the call to theDataTransferManagerHelper constructor takes 30 ms when it works and the Share panel opens, and takes only 3 ms when it fails and the panel does not open.  I log the creation of each of the objects within the constructor and they are not null, but the panel subsequently fails to open. The DataTansferManager is created, but the call to ShowShareUI() does nothing.

 

Thanks for any ideas on how to debug this.

 

+tom allen

Edit: Added: 

(updated 2015-07-09) Link to annoated logs and source fies

I am using Windows 10 v.10162. 

Sample source code is here:https://github.com/arunjeetsingh/Build2015/tree/master/Win32ShareSourceSamples; specifically, the WpfShareSource project, with the path toWindows.winmd updated to this:

  <HintPath>C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd</HintPath>.


Here is the method that executes in 3 ms when the share panel fails to open, and 30 ms when the panel does open.

public DataTransferManagerHelper(IntPtr handle) {    DataTransferManager = null;    var osVersion = Environment.OSVersion.Version;  // supported OS versions are specified in the app manifest    if (osVersion.Major >= 10)    {        IActivationFactory factory = WindowsRuntimeMarshal.GetActivationFactory(typeof (DataTransferManager));
        interop = (IDataTransferManagerInterOp)factory;        windowHandle = handle;        DataTransferManager dtm = null;
        Guid riid = new Guid(DataTransferManagerId);        interop.GetForWindow(windowHandle, riid, out dtm);        this.DataTransferManager = dtm;    } }

 

 

The relevant project file entries 

<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>  <PropertyGroup>    <!--Desktop refs to WinRT assemblies - https://msdn.microsoft.com/en-us/library/hh708954.aspx-->    <!--Also need ref to v8.1 Windows.winmd--> <TargetPlatformVersion>8.1</TargetPlatformVersion>  </PropertyGroup>   

<Reference Include="System.Runtime,Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"><SpecificVersion>False</SpecificVersion>    <HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll</HintPath></Reference><Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"><SpecificVersion>False</SpecificVersion><HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath></Reference><!-- complete Windows 10 API surface--><Reference Include="Windows">      <HintPath>C:\Program Files(x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd</HintPath></Reference>



+tom Cupertino, CA







Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>