Evaluating the function 'System.IO.StreamReader.EndOfStream.get' timed out and needed to be aborted in an unsafe way


Error: Evaluating the function 'function' timed out and needed to be aborted in an unsafe way. This may have corrupted the target process.

As most of my blog entries start off... I encountered this error last evening when attempting to see if a NetworkStream was at the end:

Error

Error: Evaluating the function 'function' timed out and needed to be aborted in an unsafe way. This may have corrupted the target process.

The debugger left me with the above error when I was trying to inspect the value of a StreamReader in Visual Studio. The core issue was that I had called StreamReader.EndOfStream to determine if the stream was at the end and that call blocked the application indefintely. Had I not put a debug point on the line in question the process would have frozen all together with no hope of pausing Visual Studio to peek at the objects contents.

Additional Reading

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.