MS Surface Gotcha When Developing on x64 Platform
If you’re getting into MS Surface development and your development OS of choice is a x64 flavor of Windows Vista or Windows 7, there are several things to watch out for. Fortunately several people have already blogged about how to patch the SDK installer so you can install it on the x64 platform. Most of such blog posts, like Steve Robbins’ post also detail how to fix several executables so they will not automatically attempt to run under the x64 CLR. Steve also goes on to show you how to configure the build settings of the SDK samples so they are forced to run under the x86 CLR. If you followed everything Steve laid out, you should be good. If, like me, you create a new solution and start adding Surface apps to it and forget to alter the build configuration, you’ll run into a very un-intuitive snag.
If you don’t alter your build configuration for every Surface application you build as described in Steve’s blog post, your application will still compile, attach to the Surface Simulator, and even render your app as it should upon startup. But once it attempt’s to read input (a touch if you're on the actual Surface, a mouse click if you’re running under the Simulator), a NotImplementedException is thrown from within the bowels of the Microsoft.Surface.Common framework. NotImplementedException? WTF!? Yeah, that’s what I thought, too. That sort of exception usually comes from incomplete APIs being released with stubbed out methods. Not sure why it happens when the Surface app has attempted to run under the x64 CLR, but it happens and it’s not immediately apparent that it was your mistake. At any rate, save yourself some time profiling and beating your head against the monitor and refer to Steve’s article. He shows you how to alter the build configuration and target the x86 platform explicitly. There is no harm in deploying your application under these conditions, since all Surface machines are currently 32-bit Vista machines at heart.
Hope this saves someone some time. Happy Surfacing!