Solve: Cannot find "Windows Desktop Extensions SDK" when click Add Reference in UWP project

I configured new applications and data to be put into non-default storage:


With this setting, I installed VS2017 and Windows 10 SDK, everything seems fine, however I noticed that “Windows Desktop Extensions SDK” and other Extensions SDKs cannot be found when click Add Reference in a UWP project any more. Tried reinstalling Windows 10 SDK 17134, 16299, repair VS 2017 15.8.1, nothing changed:


Finally I found this solution:


D:\Windows Kits\10\Extension SDKs


C:\Program Files (x86)\Windows Kits\10

Restart VS 2017, it works immediately:


How to capture crash dump for Desktop Bridge Converted or UWP app

Here is the guide on how to capture crash dump for UWP and Desktop Bridge Converted Apps:

1. Install Windows SDK which includes Windows Debugger (by clicking Install SDK)




2. Only select Debugging Tools for Windows to finish install.



3. Open Powershell Command, run this command to get your application ID:

Get-appxpackage | select-string WPFUWP

For example, I go the result: WPFUWP_1.0.0.1_x86__s46g25shpckvj for my App WPFUWP.

4. Based on your app bit, open Command Window, use 32bit (x86) folder or 64bit (x64) folder of Windows Debugger, run this command (my wpfuwp is 32bit app, so I choose Debuggers\X86) to enable debugging tool for my App:

“C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\plmdebug.exe” /enableDebug WPFUWP_1.0.0.1_x86__s46g25shpckvj “C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\WinDbg.exe -c g”

5. Launch the App and recreate the crash issue. The Windbg will auto-break the crash point, and stop App running or existing.

6. Open Windbg, in the command line, run this command:

.dump /ma /u c:\output\crash.dmp

Then can start check the crash.dmp as postmortem analysis by debugging expert.

After getting dump, can run this command to auto attach debugger on my app:

plmdebug /disableDebug WPFUWP_1.0.0.1_x86__s46g25shpckvj




How to check if Centennial App is ready

Install latest Win 10 SDK if you don’t have (till 2017 April, its version is 15063), Windows 10 should be the matched version:

Run command:

C:\Program Files (x86)\Windows Kits\10\App Certification Kit>appcert test -appxpackagepath C:\Projects\app.appx -reportoutputpath C:\Output\MyReport.xml

The MyReport.xml contains test result and you can follow it to fix known issues. Digitally signed file test, File association verbs, Debug configuration test are optional.

For more details, refer to:



How to resolve this DAC error [cannot set "Executable”, because only string can set XmlNode attribute]

When application folder contains “App.Publish“ folder [ClickOnce output folder], and run the Desktop Application Convert with similar command:

DesktopAppConverter.exe -Installer c:\release\output -Destination c:\result -PackageName “yourapp” -Publisher “CN=xxxxxxx-xxxx-xxxx-xx-xxxxxxxxxxx” -Version -appid “yourapp” -makeappx -AppExecutable “yourapp.exe” -packagearch x86

you will meet this kind of error in the DAC log:

[2017-08-16T16:21:26] An error occurred converting your application. Here is the full error record:


PowerShell Error Record:

[cannot set “Executable”, because only string can set XmlNode attribute]

無法設定 “Executable”,因為只能使用字串值設定 XmlNode 屬性。

PowerShell Stack Trace:

位於 SetExecutable,C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.0.2.0_x64__8wekyb3d8bbwe\manifest\Manifest.ps1: Line 517

To solve this, please remove the “App.Publish“ folder, which contains the executable exe and confused DAC.



How to correct Publisher ID and package the converted app

Install Win 10 SDK if you don’t have:

Latest version:

Anniversary version:


In the AppxManifest.xml file of your converted application you will find an entry similar to the following one:

<Identity Name=”myApp”



Version=”″ />


The value of the Publisher attribute should match the publisher id (CN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx) of the Store account of your dev center:, for example.


After modifying the appxmanifest.xml, please use the makeappx.exe to package the application again:

C:\Program Files (x86)\Windows Kits\10\bin\x86>makeappx pack /d “C:\myapp\PackageFiles” /p c:\Output\myapp.appx /l



Enable In-App Product Purchases for Desktop Bridge Converted Applications

Desktop Bridge helps developers gradually migrate traditional apps to the Universal Windows Platform (UWP). The In-App Purchase (IAP) in Windows Store is an important scenario to monetize the converted apps. When working with developers on this scenario, I notice certain obstacles are in common, for example:

a. Porting old .Net or unmanaged applications to use the IAP UWP APIs.

b. Didn’t use async calls properly in UI apps and caused hang/deadlock

c. Default purchase windows failed to popup

d. Need accurate guide to follow IAP testing with current Windows Store APIs

Here I introduce the IAPWrapper solution to solve above issues for converted Win32 Desktop Applications, and also show how easily to use the the IAPWrapper in different scenarios:

a. WinForm in old .Net version

b. WPF app with latest .Net version

c. Win32 App in C++

d. Unity Win32 App in old .Net version

Note: The sample code is put on:

Many converted Win32 Desktop apps were developed in unmanaged code or old .NET version which cannot directly call current UWP Store APIs, in order to eliminate this gap, let’s create an .Net IAP Wrapper library. This wrapper will finally leverage DLLEXPORT nuget package to export function entries, which can be used by different kinds of Apps easily. Below are detailed steps:

Create an IAP Wrapper Project:

1. Create a Win32 .NET class library project. The target frame work can be 4.6.1. I uses VS2017 as a quick start.

2. Add two references to allow this Win32 dll calls UWP APIs and async/await properly:

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework


3. Add statements to use necessary namespaces:

using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Windows.Services.Store;

4. Follow this guide to call a StoreContext object in class library project that will be uses the Desktop Bridge:

In Converted Win32 Desktop App, it needs to configure the StoreContext object to specify which application window is the owner window for modal dialogs. The functional sample code is:

 public class IAPWrapper
        //Declare the IInitializeWithWindow interface in your app's code with the ComImport attribute
        public interface IInitializeWithWindow
            void Initialize(IntPtr hwnd);

        //Get a StoreContext object by using the GetDefault method 
        private static StoreContext storeContext = StoreContext.GetDefault();

public static string Purchase(string storeID)

                return "Done";
            catch (Exception ex)
                return "Exception:" + ex.ToString() + "exMessage:" + ex.Message;

        static async Task PurchaseAsync(string storeID)
              IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)storeContext;
            var ptr = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;

            //Call the IInitializeWithWindow.Initialize method, and pass the handle of the window 
            //to be the owner for any modal dialogs that are shown by StoreContext methods.

            var result = await storeContext.RequestPurchaseAsync(storeID);

            if (result.ExtendedError != null)
                MessageBox.Show(result.ExtendedError.Message, result.ExtendedError.HResult.ToString());

            MessageBox.Show("Purchase Finished with status " + result.Status);

5. Install DLLExport nuget package to the project:


After installed the nuget package, you may see a setting dialog box pups up, can refer to this picture to configure (name space is still IAPWrapper here):


For more details of DLLExport, please refer to:

6. Add one statement to declare DLLExport before the Purchase (string storeID) function that we need to export from this dll:


        public static string Purchase(string storeID)

7. Use X86 or X64 option to build the library.

Note: AnyCPU option doesn’t give us the expected exported function entries.

If I build it in X64 option, using “dumpbin iapwrapper.dll /exports” can see the “Purchase” is listed in export section


This means we can load the library and function address to call it directly.

If build it in AnyCPU configuration option, the export function will not show up:


8. After above steps, we will get the IAPWRAPPER.dll, now can use it easily in various scenarios.

To move forward, firstly we should avoid below known issues:

1. Don’t call Task.Wait directly, this will cause UI apps deadlock issue. For detailed info, refer to:

Async/Await – Best Practices in Asynchronous Programming

2. Don’t run app with admin privilege, otherwise may not see the purchase diaglog box popup.

3. Make sure the purchase option runs in the UI thread, refer to:


4. The store ID used as parameter is the 12 characters (9pxxxxxxxxxx) of add-on on your developer portal, not product display name 001.


Now we start go through each scenario to see how to call the IAP functions:

Scenario one: Use IAPWRAPPER in .Net 2.0 Winform app

1. Add DLLImport statement and call the Purchase function:

public partial class Form1 : Form
        extern static IntPtr Purchase(string storeID);
        public Form1()

        private void Demo_Click(object sender, EventArgs e)

2. Build the app, and put IAPWRAPPER.dll into the output folder.

Run the app, and trigger the purchase, we can see default purchase windows pops up (depends on your account setting, authentication window may occur as well,):




Scenario two: Use IAPWRAPPER in .Net 4.6 WPF app

1. Add DLLImport and call purchase function:

public partial class MainWindow : Window
        extern static IntPtr Purchase(string storeID);
        public MainWindow()

        private void Demo_Click(object sender, RoutedEventArgs e)
            catch (Exception ex)
                MessageBox.Show(ex.Message + ex.StackTrace);


2. Build the app, and put IAPWRAPPER.dll into the output folder. Run the app, it will show up the same purchase window.


Scenario three: Use IAPWRAPPER in C++ Win32 app

1. Use LoadLibrary and GetProcAddress to call the Purchase function:

HINSTANCE hGetProcIDDLL = LoadLibrary(L"IAPWrapper.dll");
			PURCHASE purchase = (PURCHASE)GetProcAddress(hGetProcIDDLL, "Purchase");
			char *s = purchase("9pjp4testztd");
			MessageBoxA(hDlg, s, "Return Info",0);

2. Run the app, it will show up the same purchase window.


Scenario four: Use IAPWRAPPER in UNITY Win32 app

1. Put IAPWrapper into the Assets\Plugins folder

2. Add DLLImport and Purchase function as below:

public class IAPCaller : MonoBehaviour
    extern static IntPtr Purchase(string storeID);
    private void Update()
     void TaskOnClick()
        Debug.Log("You have clicked the mouse!");

3. Build the app as Win32 app, and run it.



Here we discussed how to quickly integrate the essential Windows IAP function into different kinds of Win32 Apps. You may expand your IAPWrapper for more specific usage scenarios, checking licensing, trail status, enumerate add-ons, etc. Can refer to:

After completing above tasks, please follow the 5 bullets exactly to ensure your applications are ready for IAP and Store function tests:

Thank you!

Get Rid of “The image file must be smaller than 204800 bytes” from WACK Report

When using Desktop Converter to auto produce APPX package, you may notice even the image file’s size is small enough in your app packagefiles folder, however the output APPX is still failed on WACK checking on image file size part, just similar to this error:

“The image file “AppMedTile.scale-400.png” must be smaller than 204800 bytes.”

To solve this:

1. Make sure the image file’s size is small enough in your app packagefiles folder (\PackageFiles\Assets), if not, use mspaint or other tool to reduce the picture size.

2. Get latest Windows 10 SDK, run this command to manually package the app:

D:\Projects\myapp>”C:\Program Files (x86)\Windows Kits\10\bin\x86\makeappx.exe” pack /d .\packagefiles /p D:\test\myapp.appx /l

3. [Optional] Run below powershell scripts to sign myapp.appx manually as well (this is for your local installation and test purpose):

cd “C:\Program Files (x86)\Windows Kits\10\bin\x86”

.\MakeCert.exe -r -h 0 -n “CN=B1XXXXXX-990F-467C-B5C2-XXXXXXA0BDFA” -eku -pe -sv d:\output\3d.pvk d:\output\3d.cer

.\pvk2pfx.exe -pvk d:\output\3d.pvk -spc d:\output\3d.cer -pfx d:\output\3d.pfx

.\signtool.exe sign -a -f d:\Output\3d.pfx -fd SHA256 -v D:\test\myapp.appx

4. Now run appcertui.exe to check the myapp.appx again:

Run “C:\Program Files (x86)\Windows Kits\10\App Certification Kit\appcertui.exe”, Select Store App (it will create a report,but need you set the output path everytime), make sure the report shows PASS result: