16

I have a conditional breakpoint and the condition checks the value of a string and stops if it's true. It stops but then a window opens saying:

The condition for a breakpoint failed to execute ... The error returned was 'Evaluation of method System.Collections.Specialized.NameValueCollection.get_Item() calls into native method 'System.Globalization.TextInfo.Internal.GetCaseInsHash(). Evaluation of native methods in this context is not supported.'. Click OK to stop at this breakpoint.

I searched for answers but they said enable Managed Compatibility Mode, which didn't work.

Questioner
  • 2,451
  • 4
  • 29
  • 50
  • Do you have other VS Environment to test it? The similar issue has been reported before: https://stackoverflow.com/questions/41169728/system-math-abs-calls-into-native-method-system-appdomain-getid, if possible, you could share a simple sample using one drive, I will help you debug it using different VS versions, at least, we could know that whether it is related to the VS versions or it really has a limitation for it. If you could share it, please also tell me where and how you set the condition breakpoint. – Jack Zhai Sep 20 '17 at 07:34
  • @JackZhai-MSFT Yes, I just tried it in Visual Studio Community 2017. Exact same result. The answer you linked was no help. – Questioner Sep 25 '17 at 13:23
  • Project > Properties > Debug > uncheck option Enable Native code debugging, how about the result? In addition, do you restart your app after you enable Managed Compatibility Mode? No sample is hard for us to troubleshoot this issue, if possible, share a simple sample using one drive would be better. – Jack Zhai Sep 26 '17 at 10:09
  • Didn't work and I ended up giving up and re-publishing and using a new condition that didn't call any methods the debugger didn't like. – Questioner Oct 05 '17 at 09:31
  • This worked for me: https://stackoverflow.com/questions/32276732/error-when-using-a-conditional-breakpoint-on-system-type – JoanComasFdz Oct 17 '17 at 14:18
  • i was getting this error when i had added some linq expressions in my Watch window. When I used the watched expression directly in code. i did not receive any error. – user1579234 Jul 25 '20 at 18:04

2 Answers2

6

Checking "Enable the Visual Studio hosting process" under project debug settings solved this problem for me.

Chris
  • 1,101
  • 8
  • 13
5

You could perhaps also manually add the breakpoint to your code, like so...

if (conditionThatMeansStop) 
{
    System.Diagnostics.Debugger.Break();
}

That's how I got around...

Evaluation of method System.String.op_Equality calls into the native method System.Environment.FailFast()

... in a similar situation where I was trying to set a conditional endpoint that checked a string's value.

ruffin
  • 16,507
  • 9
  • 88
  • 138