Visual Studio 2019: Error pop-up appears: "To prevent an unsafe abort when evaluating the function..."
Asked Answered
M

3

17

I am facing an issue with Visual Studio 2019 (version 16.3.8), when starting an ASP.NET Core 3 WebApi project.

After clicking OK the project starts and runs without any issue. However the pop-up keeps nagging me every time I start my solution.

  1. How can I stop showing it?
  2. What is it trying to tell me anyway?

enter image description here

Micahmicawber answered 8/11, 2019 at 10:12 Comment(2)
I just submitted a similar question at #58793611. These may be the same issue.Fencing
Check this thread and see if that helps.Heterosexuality
M
13

There seems to be two possible solutions to this, that at least worked for me being on Visual Studio 2019.

Solution

Goto Tools => Options => Debugging => General and then either enable Use Managed Compatibility Mode (thanks to Nan Yu) or disable Enable property evaluation and other implicit function calls.

The second solution faces the drawback that when being in break mode, we have to manually hit refresh on the locals window to see a variables content.

Background

The message is telling us, that our system state may get changed when being in break mode due to implicit property evalution.

By default, we tell Visual Studio debugger to try and evaluate properties implicitly. This of course requires running code while we are braked, and not only display memory content. Running code, might potentially change the state of the system, which is not always what we want. For example, I might be increasing a counter every time the property is accessed, which means that when the debugger will try to evaluate the property, my code will run, the counter will be incremented, and my system state is changed, even though I am braked.

https://blogs.msdn.microsoft.com/eliofek/2012/12/12/why-do-we-get-the-function-evaluation-requires-all-threads-to-run/

Micahmicawber answered 11/11, 2019 at 8:27 Comment(2)
Why does this message appear intermittently, and in some solutions not at all?Ariannaarianne
I'm not sure the article you referenced is talking about the same thing, at least not exactly. The message in the question seems to be saying 'there was a reason to stop ("unsafe abort") but we didn't'.Ariannaarianne
A
6

I had some variables in my watch window that was causing this error popup to happen. Just remove them from your watch window and the error popup should no longer display.

Apportionment answered 16/7, 2020 at 11:24 Comment(0)
V
3

For Visual Studio 2022 Untick the option below: Tools > options

Valentin answered 8/12, 2023 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.