How to deploy an Universal Windows Project on real device mobile?

I'm trying to debbuging my app on real device (lumia 830 with windows 10 mobile 10.0.10581.0) Developer Mode is ON on both devices (mobile and PC), but when I'm deploying my app on my device I've got an error (DEP6100 and DEP6200). Howevere i can easily emulate on emulators and my PC, couldn’t understand whats the problem.

I googled a bit and I discovered how to resolve the problem.


  • Create a Registry Key in: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SirepClient] (Probably you will need to create it)
  • Create a dword with name "DisableProtocol3" and value 00000001
  • Restart Visual Studio and try deploying the solution back again.

It's a provisional solution meanwhile a patch is included in Windows 10 mobile. We will have to consider deleting this key after that.

If you want to inspect your device, connect your device via USB and open a browser and type

And you can watch your device in action!

Windows 10 Device – Home


Windows 10 Device – App Manager


Windows 10 Device – File Explorer


Windows 10 Device – Processes


Windows 10 Device – Performances (in real time!)



In my previsious post (How do I get a Unique Identifier for a Device within Windows 10 Universal?) I talked about how getting a unique Id for a device. I’ve found another way.

In the registry there is an unique ID generated during Windows installation and it won't change until you reinstall Windows. You can find such ID in HKLM/Software/Microsoft/Cryptography, it's a string named MachineGuid.

If you can identify a component you're pretty sure that won't change (motherboard for example) you may use a simple WMI query to get its serial number but you should always provide a fallback because many many MBs returns a fake S/N (and virtual machines may returns always the same one). What's the proper solution...well it depends on what you have to do with that ID. Identify the user? Check for license? Encrypt data? Each of these has a different "best practice" for ID.

Get an unique ID for the device
If you have to identify a particular device (regardless to the user) you have many options, what I'd prefer to do is to generate an ID using only stable data (S/N from motherboard and BIOS, for example). This won't help you if he/she completely renew its hardware but it should be stable enough (but you have to define what is enough in your case). You may even use the S/N of the primary disk (with portable devices it's pretty stable and you may even use it in combination with other serial numbers to build your own ID). You can get this informations through WMI or (if you're targeting WinRT) through specific bytes of the ASHWID structure.

Encrypt data
In this case you have to think when data may be unrecoverable. If with a small hardware change your users won't be able to read their previous files well, they'll be unhappy. In this case I would suggest to use the MachineGuid, unless they reinstall the OS they wouldn't have to worry (but do them a favor and provide a way to read back that GUID somewhere). If you're sure you're targeting a portable device like a phone or a tablet then disk serial number (or CPU ID, if available, or MB or BIOS) may be appropriate too (because it's pretty uncommon they'll change).

I would use a combination of many (stable) IDs. As for an unique identifier for the device you can't be sure nothing will change. In the past MAC address was vastly used for this but mobile devices changed these rules (because it's easy to turn off a NIC). You can still use them but you have to put extra care (and code) to manage that situation. Again a combination of multiple IDs (chosen carefully) can help you to minimize customers effort when they change their hw/sw setup. In this case a good compromise could be the OS serial number (not the MachineGuid). If they install a new OS then they have to update your license too (but I would use it combined with something else to be sure they won't use the same OS copy on multiple computers or virtual machines).

Note about virtual machines
If you have to target VMs too then things become more complicated. In theory an user can create multiple copies of the same VM with exactly the same hardare and software configuration. If this is an issue and if you can't address this properly (for example using a network check) I would suggest you don't support them at all (just quit if you detect a VM).

/// Here is a code example that filters form ASHWID the hardware modules
/// that are unlikely to be changed (CPU id, size of memory, serial number of the disk device and bios)
public string GetDeviceID()
    // get the hardware Profile id and convert it to byte Array
    var hardwareToken = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);

    byte[] byteArray = null;
    Windows.Security.Cryptography.CryptographicBuffer.CopyToByteArray(hardwareToken.Id, out byteArray);

    var deviceSerial = "";
    var offset = 0;

    // we filter the hardware modules that are unlikely to be changed, and aggregate them to a string.
    while (offset < hardwareToken.Id.Length)
        // CPU ID of the processor || Size of the memory || Serial number of the disk device || BIOS
        if ((byteArray[offset] == 1 || byteArray[offset] == 2 || byteArray[offset] == 3 || byteArray[offset] == 9) && byteArray[offset + 1] == 0)
            for (var i = 0; i < 4; i++)
                deviceSerial += byteArray[offset + i].ToString();
        offset += 4;

    return deviceSerial;


Happy coding!

How do I get a Unique Identifier for a Device within Windows 10 Universal?

If you google a bit about this problem, you can’t find a right solution because all people are speaking about Hardware Token. Unfortunately this functionality doesn’t exists for Universal Windows Application.

There are at the moment only a way. You have to add the Extension reference "Windows Desktop Extensions for the UWP" or "Windows Mobile Extensions for the UWP", then you can use the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Windows.System.Profile;

namespace PSC.Code
    public sealed class DeviceInfo
        private static DeviceInfo _Instance;
        public static DeviceInfo Instance
                if (_Instance == null)
                    _Instance = new DeviceInfo();
                return _Instance;


        public string Id { get; private set; }
        public string Model { get; private set; }
        public string Manufracturer { get; private set; }
        public string Name { get; private set; }
        public static string OSName { get; set; }

        private DeviceInfo()
            Id = GetId();
            var deviceInformation = new EasClientDeviceInformation();
            Model = deviceInformation.SystemProductName;
            Manufracturer = deviceInformation.SystemManufacturer;
            Name = deviceInformation.FriendlyName;
            OSName = deviceInformation.OperatingSystem;

        private static string GetId()
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Profile.HardwareIdentification"))
                var token = HardwareIdentification.GetPackageSpecificToken(null);
                var hardwareId = token.Id;
                var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

                byte[] bytes = new byte[hardwareId.Length];

                return BitConverter.ToString(bytes).Replace("-", "");

            throw new Exception("NO API FOR DEVICE ID PRESENT!");


Someone speaks about to use EasClientDeviceInformation provides a unique Id but this is working only for Windows Store Apps.

var deviceInformation = new EasClientDeviceInformation();
string Id = deviceInformation.Id.ToString();


Happy coding!

UWA Message Dialog

To show a Message Dialog in Windows 10 (Universal Windows App) you have to use Windows.UI.Popups

using Windows.UI.Popups;

After you can create a basic dialog like this:

// Create the message dialog and set its content; it will get a default "Close" button since there aren't any other buttons being added
var messageDialog = new MessageDialog("You've exceeded your trial period.");

// Show the message dialog and wait
var res = messageDialog.ShowAsync();

If you want to customize your button, you can use another way:

/// Click handler for the 'CancelCommandButton' button.
/// Demonstrates setting the command to be invoked when the 'escape' key is pressed.
/// Also demonstrates retrieval of the label of the chosen command and setting a callback to a function.
/// A message will be displayed indicating which command was invoked.
/// In this scenario, 'Try again' is selected as the default choice, and the 'escape' key will invoke the command named 'Close'
private async void CancelCommandButton_Click()
	// Create the message dialog and set its content
        var messageDialog = new MessageDialog("No internet connection has been found.");

	// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
	messageDialog.Commands.Add(new UICommand("Try again", new UICommandInvokedHandler(this.CommandInvokedHandler)));
	messageDialog.Commands.Add(new UICommand("Close", new UICommandInvokedHandler(this.CommandInvokedHandler)));

	// Set the command that will be invoked by default
	messageDialog.DefaultCommandIndex = 0;

        // Set the command to be invoked when escape is pressed
        messageDialog.CancelCommandIndex = 1;

        // Show the message dialog
        await messageDialog.ShowAsync();

#region Commands
/// Callback function for the invocation of the dialog commands.
/// The command that was invoked.
private void CommandInvokedHandler(IUICommand command)
	// Display message showing the label of the command that was invoked
        Debug.WriteLine("The '" + command.Label + "' command has been selected.");

Using SQLite in Windows 10 Universal apps

Using SQLite in Windows 10 Universal apps is really easy even in this preview phase. Even though Entity Framework 7 support for Windows 10 Universal apps is almost here, you still might decide to just continue using a lighter SQLite.Net-PCL library that you're used to since Windows Phone 8/WinRT.

If you are using Visual Studio 2015 RTM and 10240 SDK, there's now the official (no more pre-release stuff) SQLite VSIX package that you can download from Search for "Universal App Platform" and you're good to go! The rest of the blog post should apply to this version as well.


The next step is to add the SQLite.Net-PCL library that I already mentioned. Use the (redesigned) NuGet to do that.


It will add two references

  • SQLite.Net
  • SQLite.Net.Platform.WinRT

Now, remember the VSIX package (Visual Studio extension) installed earlier? It installs SQLite extensions that you need to reference by simply right-clicking on References and choosing "Add Reference..." and then finding the right reference under Windows Universal -> Extensions.


And that's it! You can start using SQLite!

To test it, I defined a simple model class called User.

public class User  
    public int Id { get; set; }
    public string Name { get; set; }

And then I created a table which will hold User entities.

var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (SQLite.Net.SQLiteConnection conn = 
       new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))  

Adding SQLite support to Windows 10 Universal apps is really simple! After all of the extensions are added, and the ORM/client library fetched over NuGet, the usage is the same as before. This is really neat for simpler scenarios and until Entity Framework 7 officially, fully supports Windows 10 Universal apps.

UWA: This application can only run in the context of an AppContainer

  1. Run it from VS (with or without debugging). This will actually install unpackaged version of your app, so you will see it in the start screen.
  2. Create a package to use locally. You can do this in VS by going to Store → Create App Package → Build a package to use only locally. This will create a bunch of files, including a command-line script that will actually install the app. You probably could use this method to distribute the app, but it would work only on developer-enabled computers.
  3. Publish your app to the Store. This is the only way you should use to distribute the apps to ordinary users.

Universal Windows app samples

On GitHub Microsoft have published a lot of examples for Universal Apps: the link is

This repo contains the samples that demonstrate the API usage patterns for the Universal Windows Platform (UWP) in the Windows Software Development Kit (SDK) for Windows 10. These code samples were created with the Universal Windows templates available in Visual Studio, and are designed to run on desktop, mobile, and future devices that support the Universal Windows Platform.

Universal Windows Platform development

These samples require Visual Studio 2015 and the Windows Software Development Kit (SDK) for Windows 10 to build, test, and deploy your Universal Windows apps.

Get a free copy of Visual Studio 2015 Community Edition with support for building Universal Windows apps

Additionally, to stay on top of the latest updates to Windows and the development tools, become a Windows Insider by joining the Windows Insider Program.

Become a Windows Insider

Using the samples

The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the samples and use them in Visual Studio 2015.

Download the samples ZIP

The samples use Linked files in Visual Studio to reduce duplication of common files, including sample template files and image assets. These common files are stored in the SharedContent folder at the root of the repository and referred to in the project files using links.

For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance, tutorials, and reference topics provided in the Windows 10 documentation available in the Windows Developer Center. These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for Windows.

Error : DEP3321 – Can’t deploy to Windows 10 Mobile

With Windows 10 being rolled out as I write this article, there will be updated sample Windows Platform apps available soon (today). It’s also time to update your projects.

However, you may find yourself not able to deploy to Windows 10 Mobile after updating your projects or older samples to Windows 10 (build 10240). This post will show you how to resolve this problem.

The problem

You’ll see an error something like this when deploying to a physical Windows 10 Mobile device:

Error : DEP3321 : To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.10240.0 or higher. You currently are running version 10.0.10166.0. Please update your OS, or change your deployment target to a device with the appropriate version.

The error is pretty clear but how do we fix it? The resolution is with the MinTargetVersion setting.

The fix

We need to drop the lowest version your app targets to the version that your device has running, we can do this in one of two ways; through the project properties UI editor or manually edit the XML of the csproj file. I will show you how to do it manually because in some cases, the UI’s MinTarget dropdown list won’t show the lowest SDK if you do not have it installed. Below are the steps to fix it.

NOTE: Skip to step 3 if your project is already unloaded (it will show (unavailable) next to the name)

1) Right click on your project in Visual Studio

2) Select “Unload Project“, it will now appears as ProjectName (unavailable)

3) Right click on the unloaded project and select “Edit projectName.csproj

4) Locate the <TargetPlatformVersion> and <TargetPlatformMinVersion> items in the first <PropertyGroup>.

Here’s the “Before” screenshot:


5) Change the TargetPlatformMinVersion to the version that the error stated you are running. In this case, it’s 10166. Here’s the “After” screenshot:


6) Now Save and Close the file

7) Right click on the project again and select “Reload Project

8) Rebuild the project and deploy to device. Now you should be up and running!



Planet Xamarin

Planet Xamarin