unable to evaluate expression whilst debugging

后端 未结 5 1032
遥遥无期
遥遥无期 2020-12-02 22:33

When debugging asp.net code (running against IIS, and using Visual studio 2013) and in a breakpoint and trying to evaluate a variable using quick watch i quite often get \"u

相关标签:
5条回答
  • 2020-12-02 22:41

    The C# debugging engine relies heavily on the CLR debugger in order to evaluate expressions. That message indicates that the CLR is in a state in which it is unable to perform simple evaluations and the reasons for that can include the following

    • a local variable is optimized away
    • the thread is stopped in a GC unsafe point
    • a previous function call caused the debugger to get into a bad state and hence further evaluations simply aren't possible
    0 讨论(0)
  • 2020-12-02 22:42

    I have faced this for specific project and the reason is Costura.Fody (embeds all DLLs into the executing assembly).

    In this case you can disable Costura.Fody.

    1. Comment out Costura from FodyWever.xml

      <Weavers>
        <!--<Costura />-->
      </Weavers>
      
    2. Disable the clean reference target (if included) in *.csproj

      <!--<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild">
          <Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%
           (DestinationSubDirectory)%(Filename)%(Extension)')" />
          <Exec Command="DeleteEmptyDirectory.bat" />
        </Target>-->
      
    0 讨论(0)
  • 2020-12-02 22:43

    I faced it today with VS2013.

    Goto Tools --> Options --> Debugging --> General --> Scroll to the bottom for "Use Managed Compatibility Mode" and Select the option.

    Screenshot from the blog(url below): enter image description here Restart you debugging. Hope it helps others.

    What Helped Me is below!

    • Visual Studio 2013 Could not evaluate Expression Debugger Abnormality turned out to be very helpful.

    • Also, you could see @Dreamers answer Unable to debug managed code using visual studio 2013

    0 讨论(0)
  • 2020-12-02 22:47

    Go to Tools --> Options --> Environment --> General --> check "Automatically adjust visual experience based on client performance" option.

    0 讨论(0)
  • 2020-12-02 22:48

    Some of these options change over time - and top rated solutions in other answers don't seem to all exist any more - searching the options dialog can help.

    Right now for a ASPNET Core project I found this, and enabling it seems to be helping:

    Suppress JIT optimization on module load (Managed only): Disables the JIT optimization of managed code when a module is loaded and JIT is compiled while the debugger is attached. Disabling optimization may make it easier to debug some problems, although at the expense of performance. If you are using Just My Code, suppressing JIT optimization can cause non-user code to appear as user code ("My Code"). For more information, see JIT optimization and debugging.

    If it doesn't seem to help I'd suggest turning it off again.

    0 讨论(0)
提交回复
热议问题