CSHARP-703: fixed issue with infinite loop and bad error message.