Windows 10 UWP – Emulator- The Revenge

I’ll tell you why UWP is suffering.  The UWP flavour of XAML is a mere shadow of WPF and the emulator is shockingly hard to get working or working reliably.  For all the warts and problems Xamarin has at least the emulators work.  At this point I’m approaching 10 straight days over the course of three months doing nothing but attempting to debug a UWP application in an emulator running on my development machine.  That’s an inordinate waste of my own life and valuable development time.

Imagine that, a Windows machine with a Windows IDE and a Windows VM engine fails to just work, WTF??  Microsoft, there is no excuse for this.   From all my hours of reading it seems droves of developers are failing to make meaningful use of their own freakin emulator.  I’ve been plugging away at trying to get this to work, on and off for over three months.  I find myself with regained enthusiasm for the problem to start trying again.  Go through the same pain and exasperation and give up again in complete and utter frustration.

Utterly ridiculous.

I’ve tried every solution I’ve found online and nothing has fixed the problem.  You can see long posts on StackOverflow discussing a shit-ton plethora of potential solutions.  The very fact there are such a vast array of potential solutions points to this entire feature of UWP and Windows Phone development needing a lot of TLC from Microsoft.

Why can I debug an iOS application crossing not just the network for compilation but also across operating systems with ease yet I cannot do the same internally to my development machine?  This is a seriously stupid situation.  Some of these discussions span years and multiple Windows OS versions and emulator versions.  Threads starting in 2012 and running through to today, with developer after developer failing to get a proper solution.  Or finding a solution that works until you reboot the machine and have to perform a load of random steps to get it working again.  I’ve wasted a day here and a day there trying to get this to work and it looks like I’m very close to just throwing in the towel – permanently.

In fact this is making me completely reconsider continuing any work with UWP at all.

You can see from threads like this one and this one and this one and this one (you can see a pattern here?!) that lots of people either had (the lucky ones) or are still having issues.  This post in particular was originally written in September of 2012, it has comments up to January 2016 and here I am looking at it March 2017 trying to solve the same problems.  5 years later people are still struggling with Hyper-V and emulating a Windows Phone.  This smacks of a stupid and a hugely counter-productive situation to put your developers in.

It also shows that it is a severe and very real point of pain for many and far from an isolated obscure networking issue.  At least give us some better useful exceptions, or things to Goolge Bing.  At this point I’m seriously underwhelmed with UWP development to the point where I really don’t care about it being a success or not.  Is that really where Microsoft wants me or other developers to be?

I can emulate ALL THE OTHER PLATFORMS with nothing more than a press of a button, but using a completely Microsoft owned tool-chain fails miserably.  It’s no wonder the Windows Store shelves are threadbare and the UWP platform is thus-far an utter flop.

I guess you can tell from the tone in this post that I’m far from happy with this situation, it’s an insanely frustrating situation all round.  I don’t give up on problems easily but this one has me utterly beaten.  I would list all the solutions and voodoo that I’ve tried in order to get this working but frankly I’m struggling to even keep the enthusiasm to finish this blog post explaining my own personal failure.

I guess I’m going to leave this rant alone now unless I find more energy or enthusiasm for the task, this maybe my first and last ever post on UWP.  Frankly, I’ve got better things to do with my time and lets face it, even if I could be arsed to dive into this again and finish my UWP application it’s not going to make me a millionaire anytime soon …


View Model Value Change Tracking in MvvmCross & Xamarin

Change tracking object contents at first might seem like an easy or straightforward task but there are lots of pitfalls and potential issues with many solutions.  What works in your situation might not work in other situations due to implementation details.

The most obvious use of change tracking is at the heart of many ORM frameworks.  These frameworks manage data, often through proxy classes, in order to track what needs to be written to the data store when inserts or updates are applied.  These are often very granular and can be significant performance drains if misused or used in situations when not really required.

Most solutions you’ll find simply add an IsDirty property on a base class or interface and then just set that to true in any property setters in order to mark the class as dirty.  Other solutions maybe a little smarter and have a SetProperty() method that compares the new value to the current value and only executes the set if the value is new or unequal.  Whilst this isn’t change tracking it is at least efficient in view models when bound to interfaces.  An example method might look like this:

protected void SetProperty<T>(ref T backingfield, T value, Expression<Func<T>> property)
    if (Equals(backingfield, value))

    var mem = property.Body as MemberExpression;
    if (mem != null)
        var prop = mem.Member as PropertyInfo;
        if (prop != null && prop.CanWrite)
            // take advantage of any setter logic
            prop.SetValue(this, value);
            // update backing store
            backingfield = value;


If you’re trying to compare to original values you could start tracking each change to each property and working out if the current value has been used at any point in past.  This could very easily become a very bloated object graph.  You’re also still left in a situation where developers have to remember to call the SetProperty() method and not just set a property either directly or miss the public class API altogether and set the private backing field and negating any setter logic anyway.  If you don’t want to have property changed code in all your setters this can be a good approach if a little more expensive.

Negating all of these issues in one solution is extremely hard but minimising them is a must.

My Solution

I wanted a fairly simple IsDirty semantics at the class level.  I wanted my solution to just take care of itself and I didn’t want to have to do too much work in order to get this reliably functioning.  I also want it to be efficient and smart enough to accurately report that the class data really had changed and also wasn’t the same as the original values. My requirements where:

  • Entirely PCL (Portable Class Library) based implementation
  • Behaves in data binding situations
  • Attribute-driven Opt-In
  • Complex reference & value types included in object graph
  • Public only tracking (this is a view model after all!)
  • Filtering properties on Type or Name (string fuzzy matched)
  • iOS, Android, WP & MvvmCross friendly
  • As performance & memory efficient as possible
  • Class level monitoring only
  • Minimal extra library dependencies

So given these change tracking requirements I have coded my solution and I’m going to include all the code in a GitHub GIST below.


I wanted this to be as simple as possible pollute the code as little as possible.  I think it’s OK at the moment but will no doubt change and hopefully get better.

Property Attribute Example

If you use the attribute only those properties will be monitored, all other properties will be ignored.

public class PersonViewModel : MvxViewModel
    // ignored
    public string Name { get; set; }
    public string DisplayName { get; set; }

IsMonitoring Example

To start the monitoring, at some point after you can guarantee that all the values you regard as “clean” available in the object set Ismonitoring to true.  This forces a the calculation of an MD5 value for all the properties, now any subsequent calls to the IsDirty getter will compare this hash value to a newly created one with the current data.

You can reset the clean hash at any point by simply setting IsMonitoring to true again.

public sync void Init(int id)
    var data = await _myapiClient.GetPersonAsync(id);
    Mapper.Map(data, this);
    IsMonitoring = true;

Dependencies & PCL

The basic design has two dependencies.  Since I already had Newtonsoft.Json used in my project I have made use of parts of this and in order to implement the MD5 object hashing I have had to add a library – the xBrainLab.Security.Cryptography library available on codeplex.  Weighing in at 9,728 bytes this isn’t really much of a concern.

Basic Change Tracking Design

The basic design is that when IsMonitoring is set to true an object immediately generates an MD5 hash of all the relevant properties (default minus filters or explicitly opted in).  Then each subsequent call to IsDirty will first generate a new MD5 hash of the current values and compares that to the stored “clean hash”.

Hash Values (MD5)

Hashing in PCLs isn’t the norm so we have to use a library.  When generating the hash the object is first serialised to a memory stream using a JSON.NET serialiser.  This is then MD5 hashed and either stored or compared in order to calculate if an object has changes since monitoring began.

You can also set a newly minted clean hash by simply setting IsMonitoring to true on live objects.

Class Serialisation

The serialisation is all handled my JSON.NET and it’s built in serialiser.  I did try using the BSON serialiser as this may have a performance gain but it seemed to be erroring too often so I may have to revisit this.  There is a custom contract resolver that controls what is or isn’t to be tracked.  If a class has any properties marked with the IsDirtMonitoringAttribute then only these marked properties will be tracked.  If none of the properties are marked with the attribute then all public properties will be included in the change tracking minus any properties of the same type as the filter types or property name masks in the name filter.


It’s not particularly scientific or probably that accurate but I have added a unit test that monitors it’s execution time.  The test performs 100,000 IsDirty calls in a loop and will fail if it takes more than a second to complete based on the built in StopWatch class in System.Diagnostics it’s about as accurate as I’m needing.  Considering this will be called pretty infrequently and usually on a background thread this performance doesn’t concern me.  I have now implemented this on a few classes in an iOS application and I haven’t noticed any runtime issue (as yet!).

Anyway, enough wibbling as I should be out Christmas shopping … here’s the code … any comments or improvements really welcome.


MvvmCross Beta5 & SidePanel Navigation Sample

There is a new release of MvvmCross yesterday that takes the platform to v4 beta 5 that was released yesterday.  I’ve also contributed a new v4 sample project which provides cross platform side panel navigation to iOS and Android application.  You can check out the new version here and the sample is here.

You can see some screen shots of the sample applications below:

droid_menu_closed droid_menu_open ios_menu_closed ios_menu_open


Learning MvvmCross

Learning a new technology can sometimes be a very time consuming and error prone process.  The more complex the technology the longer this process can go on for.  When I was first getting my head wrapped around WPF and using the MVVM pattern this was a long process.  WPF is massive and very complex.  MvvmCross whilst not nearly as large is a very complex framework in itself.

Having said that I’m literally amazed at just how much Stuart Lodge manages to produce in terms of tutorials, write-ups, videos and code.  For that reason alone it’s worth your time to investigate.  Below I’m starting to compile a list of resources that I find useful along my own journey of using this framework.


MvvmCross Source



This is a series of really good videos produced that demos how to achieve a very large number of basic and advanced scenarios using Xamarin and the MvvmCross libraries.  Stuart has put a lot of time and effort into producing this and it’s well worth your time to dive in from time to time to learn about the various features and options available on how to structure your code and applications.

MvvmCross NPlus1DaysofMvvmCross Tutorial Videos

Blog Posts

This is a partner to the code and videos and contains a lot of very good examples and tutorials.

NPlug1 Blogs Table of Contents