This could really be anywhere in that code, but based on your testing I'm going to say that it's a x86/x64 issue.

Try changing the build platform to x86.

Right click on the solution, select...