Get "Internal error in the expression evaluator" on "Add watch" function when trying to debug WCF service code (MSVS 2013)

C#Visual Studio-2013Visual Studio-Debugging

C# Problem Overview


Few days ago I moved my solution to MSVS 2013. It works fine except one thing: when I trying to debug code of my WCF service it works, but when I want to watch state of any variable it says: "Internal error in the expression evaluator". Add watch function works normal on client side, but in service code it broken. I'm trying to debug my own WCF service running on the localhost. Could you help me, how to repair this?

enter image description here

Here MSVS info: Microsoft Visual Studio Professional 2013 Version 12.0.30110.00 Update 1 Microsoft .NET Framework Version 4.5.51641 OS: Windows 8.1

C# Solutions


Solution 1 - C#

This might be a bug in the new (managed) debug engine that ships with Visual Studio 2013. Try turning on Managed Compatibility Mode (which effectively turns it into pre-2013 debug engine), located under Tools - Options - Debugging:

If this solves the issue, then I'd suggest trying to reproduce it with a small project, and then reporting it on Connect, so it could be fixed.

@bjhuffine comments below that there are other ways to enable compatibility mode, without globally disabling it (e.g. per-project). More information here: https://devblogs.microsoft.com/devops/switching-to-managed-compatibility-mode-in-visual-studio-2013/

Solution 2 - C#

According to question https://stackoverflow.com/questions/34545354/internal-error-in-the-expression-evaluator?lq=1 'Use Managed Compatibility Mode' stops "Edit & Continue". Try to check "Use the legacy C# and VB expression evaluators" option under Tools - Options - Debugging.

Solution 3 - C#

I tried Igal's answer, and it did not work for me, but I found a solution that worked for me. I cleared the Watch and started to add items again. I noticed that if I tried to add item which was not inside current sub or function then an internal error occurred.

I solved the problem by adding other items from inside their subs or functions and there were no errors again.

Solution 4 - C#

Michael Freidgeim's answer helped me debug my issue. But I want to add additional details to the cause of my issue. Only slightly related to asker's question, but his error is extremely misleading.

We were using a Telerik controls RadGrid with GridDateTimeColumn's. The MinDate property on these grids defaults to 01/01/1980 so if you bind a date to this column that is less than that you will see this error. The weird thing is that the original binding and displaying didn't cause a problem, it was only when navigating to another page that the error was thrown.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCeridanView Question on Stackoverflow
Solution 1 - C#Igal TabachnikView Answer on Stackoverflow
Solution 2 - C#Michael FreidgeimView Answer on Stackoverflow
Solution 3 - C#KomArkoView Answer on Stackoverflow
Solution 4 - C#ascrivenView Answer on Stackoverflow