114

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

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Ceridan
  • 2,376
  • 3
  • 23
  • 32

4 Answers4

230

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/

Callum Watkins
  • 2,844
  • 4
  • 29
  • 49
Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
  • 7
    This fixed my same problem with Visual Studio 2015 CTP 6. – Chris Schiffhauer Mar 20 '15 at 18:54
  • 1
    This configurations solved the issue, but the Diagnostic tools stopped to work. – Xepe May 26 '15 at 20:17
  • 6
    This fixed my same problem in Visual Studio 2015 RTM (and disabled the new diagnostic tools) but I never had this issue in Visual Studio 2013. I'll have to test this out on my home computer and compare. – ahwm Jul 22 '15 at 16:56
  • 2
    You are a genius my friend! I also found this which not only adds further explanation, but shows other ways of doing this if you don't want the big hammer global change. http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013.aspx – bjhuffine Aug 19 '15 at 14:02
  • Just a side note about an issue I had and fixed when trying this solution - when Visual Studio 2015 Community is running as Administrator, the option can be greyed out. – csharpforevermore Oct 16 '15 at 16:08
  • 11
    Just to add; if these options are grayed out, you need to stop debugging ;) – Radderz Dec 14 '15 at 12:39
  • 1
    This also fixed the same issue with Visual Studio Enterprise 2015. Thanks! – MichaelMilom Apr 16 '16 at 16:41
  • 1
    Same problem in 2015 sp1. Holy hell will they not fix this nonsense? –  Jun 09 '16 at 15:24
  • 1
    Still facing the same issue. None of the workarounds works - well not actually workarounds if they don't work ;). – atp9 Jun 16 '16 at 18:38
  • Are there any disadvantages to using the Managed Compatibility mode? – Ciaran Gallagher Oct 24 '16 at 14:39
  • When checking this option lambda expressions won't work in the direct window anymore. It fixed the said problem because I cannot run the desired code anymore that lead to said problem :-D – xmashallax Apr 20 '17 at 16:26
  • When I try to attach to the remote debugger process I get a different issue in vs 2015(update3) where it doesn't let me connect over DCOM. I've done all sorts of port opening and dcom configuration but still no luck. – JARRRRG May 04 '17 at 13:45
13

According to question "Internal error in the expression evaluator" 'Use Managed Compatibility Mode' stops "Edit & Continue". Try to check "Use the legacy C# and VB expression evaluators" option under Tools - Options - Debugging.

Community
  • 1
  • 1
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
2

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.

Community
  • 1
  • 1
KomArko
  • 21
  • 1
  • In my situation error occurs even if I added watch items inside the method scope, but this solution with "Use Managed Compatibility Mode" helps me. – Ceridan Oct 06 '15 at 06:51
0

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.

ascriven
  • 362
  • 3
  • 6