Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immediate Window: The expression cannot be evaluated. A common cause of this error is attempting to pass a lambda into a delegate. #25

Open
ycherkes opened this issue Aug 12, 2022 · 0 comments

Comments

@ycherkes
Copy link
Owner

ycherkes commented Aug 12, 2022

I can't find any workarounds. If someone can help me, I'll be very appreciated.

Steps to reproduce:

Create a Console Application, choose the .NET6.0.
Put the breakpoint in a Console.WriteLine, start the debugging.
When the debugger hits the breakpoint, put the following statement in the Immediate Window:

new[]{1,2,3}.Select(x => new{Index = x})

Select this statement, and execute any of the Dump As ... commands.

Expected result: Object is dumped successfully.
Actual result: Exception: The expression cannot be evaluated. A common cause of this error is attempting to pass a lambda into a delegate.

Notes:
There is a workaround for new[]{1,2,3}.Select(x => x) - just add ToArray() call at the end of the statement:
new[]{1,2,3}.Select(x => x).ToArray()
Also, replacing the anonymous type with a ValueTuple and ToArray runs without errors:
new[]{1,2,3}.Select((i, x) => (i,x)).ToArray()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant