Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio during Debugging: The function evaluation requires all threads to run

I'm suddenly getting a strange error while debugging. Up to now the variable in the watch windows has been showing correctly. Now I am always getting this error message in the watch windows:

The function evaluation requires all threads to run

I am not able to check any variable anymore. I am not explicitly working with threads. What can I do to get it working again?

I already disabled, as mentioned in some forums, the function: "Enable property Evaluation and other implicit function Calls" in the option window of the debugger. But without success, and it gives me this error:

Error Implicit Function evaluation disabled by the user

like image 298
Maik Avatar asked May 01 '15 10:05

Maik


People also ask

Why do we get the function evaluation requires all threads to run?

This is not an error message , this is just a hint of visual studio debugger. Other thread should run first before some variable of your code is calculated. So debugger shows this message. You could let vs to run the code in these threads and get the value.

How do I see what threads are running in Visual Studio?

To display the Threads window in break mode or run mode While Visual Studio is in debug mode, select the Debug menu, point to Windows, and then select Threads.


2 Answers

From the msdn forum:

This isn't an error in and of itself, but more of a feature of your debugger. Some properties require code to be executed in order for the property to be read, but if this requires cross-thread interaction, then other threads may have to run as well. The debugger doesn't do this automatically, but certainly can, with your permission. Just click the little evaluate icon and it will run your code and evaluate the property.

enter image description here

For further details on this behaviour check this excelent article

like image 107
MUG4N Avatar answered Oct 12 '22 10:10

MUG4N


I ran into this issue when just trying to get items from a table called "AGENCY" using Entity Framework:

var agencies = db.AGENCY.OrderBy(e => e.FULLNAME);

enter image description here

Hovering over agencies in debug mode, clicking to expand the options, and clicking Results would give the dreaded "The function evaluation requires all threads to run" with a "Do Not Enter" icon at the end that, on which, clicking did nothing.

2 possible solutions:

  1. Add .ToList() at the end:

    var agencies = db.AGENCY_TABLE.OrderBy(e => e.FULLNAME).ToList();

    List<AGENCY_TABLE> agencies = db.AGENCY_TABLE.OrderBy(e => e.FULLNAME).ToList();

    Credit goes to Hp93 for helping me come to this solution. In the comments on MUG4N's answer where I found this solution, it also mentions trying .Any() instead of .ToList(), but this gives a Boolean instead of a <T>, like <AGENCY> is, so it probably wouldn't help.

  2. Workaround - try a different path in the debug options. I found that I could click on the "Non-Public Members" > "_internalQuery" > ObjectQuery > Results View and get my values that way.

enter image description here

like image 21
vapcguy Avatar answered Oct 12 '22 12:10

vapcguy