This all of a sudden started working. I have not touched the code at
all. In fact, I've been working on a brand new solution and when I got
the new one working I tried to see what was different to the
problematic one and then that one was working too. Not sure what other
factors could affect this though.