System.Math.Abs​​()调用本机方法System.AppDomain.GetId()? [英] System.Math.Abs() calls into native method System.AppDomain.GetId()?

查看:119
本文介绍了System.Math.Abs​​()调用本机方法System.AppDomain.GetId()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的条件断点有时工作正常,有时失败,并出现以下错误:


断点的条件无法执行。条件是‘Math.Abs​​(-4.36767421599683 -x)< 1e-5’。返回的错误是对系统方法System.AppDomain.GetId()的方法System.Math.Abs​​()调用的求值。





  1. 它仅如何工作?时间?每次我运行条件断点代码都不相同时,是否会发生运行时欺骗?

  2. 如果存在,为什么Abs()的任何版本的代码都会调用AppDomain.GetId()-肯定是纯算法吗?

  3. .NET参考源显示了一种方法 extern public static double Abs(double)。难道这不是总是本地语言吗?


解决方案

首先,您需要知道调试器评估可以不要调用本机方法。 (取决于它是否



还有一点,请尝试在其他版本的Visual Studio中对其进行评估。


My conditional breakpoint sometimes works fine, and sometimes fails, with the following error:

The condition for a breakpoint failed to execute. The condition was 'Math.Abs(-4.36767421599683 -x) < 1e-5'. The error returned was 'Evaluation of method System.Math.Abs() calls into native method System.AppDomain.GetId(). Evaluation of native methods in this context is not supported.'.

  1. How does it only work some of the time? Is there runtime trickery happening where the conditional breakpoint code isn't the same each time I run it?
  2. If there was, why on earth would any version of the code for Abs() call AppDomain.GetId() - it's purely arithmetic surely?
  3. The .NET reference source shows a method extern public static double Abs(double). Doesn't that mean it's always native anyway? How could it ever work?

解决方案

First, you need to know that the debugger evaluate can't call native method. (well its depend if it real func eval or not, but even when its not real func eval we will see that its not completely true but wait...)

How does it only work some of the time? Is there runtime trickery happening where the conditional breakpoint code isn't the same each time I run it?

Yes it's strange but it could be. The debugger evaluator actually able to get the app domain id, but sometimes some error occurred and then you will get that exception.

If there was, why on earth would any version of the code for Abs() call AppDomain.GetId() - it's purely arithmetic surely?

I pretty sure that this call not relating just to Math.Abs.

The .NET reference source shows a method extern public static double Abs(double). Doesn't that mean it's always native anyway? How could it ever work?

Because for some of the native methods, the debugger evaluator has hooks that handle it in a special way. Math.Abs is one of them.


I tried to reproduce it in my Visual Studio but without success. (VS 2017)

Try to evaluate the same expression in Watch Window (with suffix of ,nse) and tell me if you still get the exception.

Just to show you an example of trying evaluate a method that call to native code: (read the error message)

One more thing, try to evaluate it in other version of Visual Studio.

这篇关于System.Math.Abs​​()调用本机方法System.AppDomain.GetId()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆