I have had this problem too on moving to 64-bit Windows 7, and the latest source code did not solve the problem.
However, I tracked it down to the use of IntPtr (handle). Some of the handles returned were outside the range of a signed 32-bit int.
private const short INVALID_HANDLE_VALUE = -1;
private IntPtr INVALID_HANDLE_VALUE = (IntPtr)(-1);
and removing any (int) casts in comparisons with INVALID_HANDLE_VALUE solved the problem for me.