53

I have .net application (GUI as well as PowerShell) built against 4.5. My OS is server 2012. When I attach my application to 2013 visual studio, the debugger is not working sometimes. Its not evaluating expression or showing locals (and also watch window/immediate window nothing works - its as if the project is build with release). But I have build with 'Debug' configuration. And as mentioned same thing works when I simply attach with VS 2012 ( yes, I have 2k13 and 2k12 SXS)

Please note that if I attach the same process with the same settings (managed debugging), to Visual Studio 2012 it always works.

I made sure the symbols are loaded (by checking modules tab in visual studio + debug + windows), break points are hit.

Any thoughts on what might be the issue? All the updates are up-to-date as well.

Its kind of annoying to launch vs 2012 just to debug, when I am using VS 2k13 IDE for development.

Regards!

Dreamer
  • 3,371
  • 2
  • 34
  • 50
  • 2
    Have you tried reverting to the old debugging engine in VS2013? http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013.aspx – Andy Jan 16 '14 at 03:26
  • @Andy, thank you. I have looked at http://weblog.west-wind.com/posts/2013/Nov/21/Visual-Studio-2013-Could-not-evaluate-Expression-Debugger-Abnormality which is essentially the same answer. And yes, it worked. Added the answer few mins before as it may be useful for others. – Dreamer Jan 16 '14 at 03:30

9 Answers9

88

If you are facing the same issue, please look at http://weblog.west-wind.com/posts/2013/Nov/21/Visual-Studio-2013-Could-not-evaluate-Expression-Debugger-Abnormality for details.

Here is the answer which solved for me:

I have set the flag "use managed compatibility mode" in Tools | Options | Debugger | General.

For details, take a look at the link as he explained it nicely as a story :)

Am happy it worked, otherwise I just had to load project in vs 2k12 just to debug it which is annoying.

EDIT on 12th June 2014

I have updated my dev environments with visual studio 2013 update 2 (http://www.microsoft.com/en-us/download/details.aspx?id=42666) (as per Maria's suggestion below) and removed "using managed compatibility mode". I will be testing my apps (ps cmdlets, gui, services) and update you in couple of weeks if the debugger is ok for me.

EDIT on 26th June 2014

I have tested my apps and luckily for me everything is working nicely :). Even the debugger is doing pretty good job with new async/await model. So, see if you can upgrade to 'update 2' - hopefully this works in your environment too?. Thanks to Maria and debugger's team!

Regards.

Dreamer
  • 3,371
  • 2
  • 34
  • 50
  • you rock, was getting "unable to evaluate expression" in conditional breakpoints. Was really annoying! Your solution worked like a charm! – Denis Apr 02 '14 at 18:12
  • Please be aware that the solution proposed here uses the old debugger engine, which will be deprecated at some point, and also misses out on all the new features that the new engine has to offer: http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013.aspx – Maria Apr 22 '14 at 20:42
  • 1
    I am working with VS 21013 Update 3, and I have enabled the debugger's "Managed Compatibility Mode", but this didn't solve the problem for me. (Nevertheless +1 to you for offering help.) – stakx - no longer contributing Nov 21 '14 at 07:16
  • What worked for me is (while debugging) opening the menu `Debug -> Windows -> Modules`, pressing `Ctrl+A` to select all, then right clicking and selecting `Load Symbols`. Even though the symbols were already loaded for the module I was debugging, I suppose something was being cached incorrectly. – Zantier Jan 23 '15 at 10:56
  • 1
    There's also an `Empty Symbol Cache` button that may have a similar effect, at `Tools -> Options -> Debugging -> Symbols`. The button is disabled while you are debugging. – Zantier Jan 23 '15 at 11:04
  • Thank you sir !!. I owe to everyone who has a solution for something and give part of his precious time to help others who struggle ... Thanks again ,, Love you man :* – Ibrahim Amer Jul 26 '15 at 14:04
  • Wooo Thanks, after so many different tries, even uninstalling and reinstalling VS2015, this finally worked. – Jérôme MEVEL Mar 16 '16 at 11:57
  • Tried Many more solutions but still not getting result! Pls provide proper solution! – Unknown_Coder Oct 30 '17 at 09:58
11

I deleted all my breakpoints and then it started working, with Visual Studio 2013 Update 1. This was one of the suggestions from the blog post mentioned by Dreamer.

What Would Be Cool
  • 6,204
  • 5
  • 45
  • 42
4

We have released a fix for the issue you are describing in Update 2 CTP 2 of Visual Studio -
Please let me know if that doesn't resolve your issue!

Thanks! Maria - Visual Studio Debugger

Maria
  • 758
  • 4
  • 9
  • When will this be an official release? We don't usually install RCs. – Denis Apr 02 '14 at 18:13
  • Unfortunately this hasn't been announced yet. I would watch for details on Soma's blog - http://blogs.msdn.com/b/somasegar/. You shouldn't have to wait too long for it. – Maria Apr 04 '14 at 20:26
  • Has anyone verified that CTP2 fixes this issue? It's not in the release notes. – Nathan Ratcliff May 07 '14 at 22:32
  • 2
    Update 2 RTM has been announced - http://blogs.msdn.com/b/visualstudio/archive/2014/05/12/visual-studio-2013-update-2-is-here.aspx – Maria May 12 '14 at 17:55
  • I can verify that after installing the above the problem is solved for me. – kroiz Jun 01 '14 at 12:57
  • After installing Update 2 for VS2013 Ultimate (when it was released), I just encountered this issue. Debugging works if I'm looking at really any of the other variables, but on one particular variable that is populated via an Entity Framework call, I cannot evaluate the expression. After enabling the managed compatibility mode, I'm able to evaluate it without a problem. – Whit Waldo Jun 18 '14 at 00:22
  • @ Xaniff - can you please log a bug on http://connect.microsoft.com/VisualStudio with your repro steps and project. That would be very helpful in investigating this issue! Thanks! – Maria Jul 17 '14 at 20:26
0

Please note that while the accepted answer probably will fix the problem for now, it's best to be aware of the drawbacks of this solution. Making this change will make VS 2013 use the older style debugger for all you projects. It is a global setting. There are other ways to locally change this for a single project. Please read here for more info on this:

http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013.aspx

tmatuschek
  • 608
  • 4
  • 15
  • 2
    Please pull the pertinent info (how to do this) out of the blog post so that your answer is complete in itself, and the link is merely for reference. Links Are Not Answers. – Marc L. May 19 '14 at 19:03
0

We have a custom expression evaluator and our own language and this warning message to change the settings always appears even after I change the project settings to those specified in the blog.

 <DebugEngines>{351668CC-8477-4fbf-BFE3-5F1006E4DB1F}</DebugEngines>

Is there something else?

Our clients are using VS2013 pro. I've turned off all the "Enable the Visual Studio hosting process" for all our projects and also added the property to our clients projects. I still see the warning each time I attack to w3wp.exe.

IMPORTANT NOTE: If your project is using the Visual Studio hosting process (the default for many project types), you must disable the hosting process for this fix to correctly change the debug mode. To disable the hosting process go to the Debug pane on the project properties page, and uncheck "Enable the Visual Studio hosting process"

learnerplates
  • 4,257
  • 5
  • 33
  • 42
0

You can resolve this error by applying below points

Sol 1:

1) Restart visual studio and re-open your project.
2) Open your project bin directory and delete DLL of that code where your debugger is not working properly.
3) Then again add DLL reference in the bin directory.
4) Remove all breakpoints.
5) Build project.
6) attach with one w3wp.exe process in attach to process window
7) Enjoy your problem has been resolved.


If above solution is not working then you can try solution that has been provided on bellow link
http://weblog.west-wind.com/posts/2013/Nov/21/Visual-Studio-2013-Could-not-evaluate-Expression-Debugger-Abnormality

0

I had a similar problem debugging where this error occurred from a return from creating a class. The class initialized fine (using "new classname()") but then it gave the "cannot evaluate expression" error on the return. Though it worked on previous visual studio versions, running on VS 2017 it crapped out.

After a lot of head banging, it turned out that private variables in the class, especially things like arraylists and other classes, needed to be declared with initial values, even if set to null.

Once that was done, everything worked, even though the solution "appeared" to have nothing to do with the problem and gave no apparent clue of where the problem occurred.

miken32
  • 42,008
  • 16
  • 111
  • 154
SteveFerg
  • 3,466
  • 7
  • 19
  • 31
0

We had this problem with PostSharp extension version 5.0.32 with VS2013 Update 5.

Our workaround was downgrade PostSharp extension to version 4.3.19 or disable it.

Rafael Miceli
  • 2,014
  • 6
  • 22
  • 34
-1

Set AutoEventWireup="true" on aspx header file. This will turn debug mode on.

Zuhair Ali
  • 19
  • 6