Paul
Paul

Reputation: 3283

Cannot evaluate conditional breakpoint in Visual Studio 2017

I have a really really frustrating error in Visual Studio 2017

I am running code via NUnit tests and get the error below

The condition for a breakpoint failed to execute.
The condition was 'value == 22'.
The error returned was 'Evaluation of method System.Decimal.op_Equality() calls into native method System.AppDomain.GetId().
Evaluation of native methods in this context is not supported.'.
Click OK to stop at this breakpoint

Can anyone help please? I have tried with managed compatibility on and off neither work.

If I have managed compatibility off, I can't debug anything at all.

public decimal MyValue
{
    get => _value;
    set
    {
        if (_value == value)
        {
            return;
        }

    _value = value;
    HasChanged = true;
}

Paul

Upvotes: 1

Views: 1468

Answers (2)

Rosalee Wolfe
Rosalee Wolfe

Reputation: 1

if you use a single equals sign in the conditional expression, it works. If you use two equal signs (like in C#), it won't.

iFcn == 2 // generates error message

iFcn = 2 //works great

(using VS 2019)

Hope this helps.

Upvotes: 0

miskender
miskender

Reputation: 7968

There are multiple reports similar to this issue in developer community of visual studio. In one of them it is stated as;

We have fixed the problem in the upcoming preview of Visual Studio 2019. Thank you for your feedback!

https://developercommunity.visualstudio.com/content/problem/314822/the-condition-for-a-breakpoint-failed-to-execute-e.html

https://developercommunity.visualstudio.com/content/problem/377921/evaluation-of-native-methods-in-this-context-is-no.html

It looks like this bug in the debugger exists for more than a year

Upvotes: 2

Related Questions