Search code examples
c#streamwebrequeststreamreader

Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack


I am getting the following exception in c#: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

When calling ReadToEnd() method from a streamreader in a web application.

If i copy and paste the same code in a console application. It works.

Any ideas

Cheers


Solution

  • That is not an exception, merely a warning from the debugger that it has trouble giving you the information you asked for. That happens. Do make sure you have set the breakpoint correctly and haven't ended up in non-managed code with Debug + Break All.