When debugging a C# project in Visual Studio 15.8.7, I want to use Linq methods like Single()
or FirstOrDefault()
in the Immediate Window like this:
allGroups.Single(ag => ag.ImportId == importId)
However, I sometimes get an error message telling me
Evaluation of method System.Linq.Enumerable.FirstOrDefault() calls into native method System.Environment.FailFast(). Evaluation of native methods in this context is not supported.
I cannot always reproduce this error, for some values of importId
it shows me the group I'm interested in, for some other values, it throws the error.
I have enabled Use managed compatibility mode
in the debugger options. What else am I missing?