为什么产生IL code与NOP开始呢? [英] Why does generated IL code start with a Nop?

查看:270
本文介绍了为什么产生IL code与NOP开始呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拖网通过我的一些组件(通过ILDASM)之一的IL和我注意到的我所有的方法,以一个 NOP 指令。

I was trawling through some of the IL of one of my assemblies (via ILDasm) and I noticed that all of my methods begin with a nop instruction.

有谁知道这是为什么?

推荐答案

组装在调试模式下进行编译。 NOP 指令不执行任何操作(即没有副作用),而是充当一个方便的指令放置一个断点。

The assembly was compiled in debug mode. Nop instructions do not do anything (i.e have no side effects), but act as a convenient instruction to place a breakpoint.

提示

如果您需要额外断点的地方进行调试的目的,你可以通过添加一对空括号,如对强制列入 NOP 在调试版本的

If you need a place for an additional breakpoint for debugging purposes, you can force the inclusion of a Nop in a Debug build by adding a pair of empty braces, e.g.

_grid.PreviewMouseRightButtonDown += (sender, e) =>
{
    _isRightMouseDown = true;

    RowColumnIndex cell = _grid.PointToCellRowColumnIndex(e);
    {} //<------ Adding a Nop allows a breakpoint here.
};

这篇关于为什么产生IL code与NOP开始呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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