I just want to know whether we can configure(preferably in form of c# code) the break-point in visual studio 2015, such that, whenever it encounters during the process execution it must execute a line of code(like, creating an object to class or calling a function of a static class and it only applicable to that process).
我只想知道我们是否可以配置(最好以c#代码的形式)visual studio 2015中的断点,这样,无论何时在流程执行期间遇到它都必须执行一行代码(比如,创建一个对象到类或调用静态类的函数,它只适用于该过程)。
I do know that on clicking on a break-point I can set the actions that it could be performed, but I do want to achieve it by code(either by communicating my requirement to debugger of visual studio or any other way) and same line must be executed by all breakpoints that i set in the current process.Thank-you in advance.
我知道在点击断点时我可以设置它可以执行的操作,但我确实希望通过代码实现它(通过将我的需求传达给visual studio的调试器或任何其他方式)和同一行必须由我在当前进程中设置的所有断点执行。谢谢你提前。
1 个解决方案
#1
0
This is not possible with Visual Studio breakpoints. What you mean with "Actions" is called a "Tracepoint", more details here.
Visual Studio断点无法做到这一点。你对“动作”的意思被称为“跟踪点”,这里有更多细节。
However, it may help you to know that you can find out whether a debugger is attached and if so, perform custom logic in your code like this:
但是,它可能会帮助您知道您是否可以找到调试器是否已附加,如果是,请在代码中执行自定义逻辑,如下所示:
using System.Diagnostics;
if (Debugger.IsAttached)
{
// call code here which gets not executed in the released version of your app
}
But be aware, users are able to attach debuggers as well, so be careful with what you plan to do in there.
但请注意,用户也可以附加调试器,因此请注意您计划在那里执行的操作。
#1
0
This is not possible with Visual Studio breakpoints. What you mean with "Actions" is called a "Tracepoint", more details here.
Visual Studio断点无法做到这一点。你对“动作”的意思被称为“跟踪点”,这里有更多细节。
However, it may help you to know that you can find out whether a debugger is attached and if so, perform custom logic in your code like this:
但是,它可能会帮助您知道您是否可以找到调试器是否已附加,如果是,请在代码中执行自定义逻辑,如下所示:
using System.Diagnostics;
if (Debugger.IsAttached)
{
// call code here which gets not executed in the released version of your app
}
But be aware, users are able to attach debuggers as well, so be careful with what you plan to do in there.
但请注意,用户也可以附加调试器,因此请注意您计划在那里执行的操作。