Thanks for the code samples. I went through them and we're doing basically the same thing. One thing I noticed is that 2013 R2 logs errors to the event viewer when I hit this code. The stack trace makes it look like NAV is trying to display a window when ERROR is executed.
We submitted a ticket to Microsoft about this and they said it's probably a defect on their end. If I find anything out, I'll post it here.
thx