Unable to debug managed code using visual studio 2

2019-01-16 10:51发布

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!

9条回答
Animai°情兽
2楼-- · 2019-01-16 11:18

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

查看更多
看我几分像从前
3楼-- · 2019-01-16 11:19

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"

查看更多
贪生不怕死
4楼-- · 2019-01-16 11:22

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.

查看更多
叛逆
5楼-- · 2019-01-16 11:28

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.

查看更多
女痞
6楼-- · 2019-01-16 11:31

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.

查看更多
Rolldiameter
7楼-- · 2019-01-16 11:37

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

查看更多
登录 后发表回答