即使调试器在该函数上中断,函数也不会执行 [英] Function not executing even if the debugger breaks on that function

查看:77
本文介绍了即使调试器在该函数上中断,函数也不会执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我写了一个代码,其中我不断循环一组函数让我们说2-3个函数。它是一个while循环,连续执行。



现在检查特定函数的执行情况我在该函数中应用了断点。我注意到调试器在该函数上中断,但从不执行它。



我还在我应用断点的函数中应用了几个断点。但是调试器从未打破过它们。这意味着编译器永远不会进入该函数。



我将复制场景:



< pre lang =cs> class 程序
{
static void Main( string [] args)
{

while true
{
fun1();
fun2();
fun3();

}


}

静态 void fun1()
{
Console.WriteLine( hello1\" );
}

静态 void fun2()
{
Console.WriteLine( hello2);

}

静态 void fun3()
{
Console.WriteLine( hello3);

}


}











有什么建议吗?我的意思是说,背后可能的原因是什么?我还写了一篇thread.sleep(200);指令。但是这个工作也有效。



如果我重新启动我的应用程序(没有做任何更改,即我不删除断点),它工作正常。



非常感谢,

Rahul

解决方案

感谢您的澄清。目前,您的示例代码是正确的;并且它的所有部分都应该可以通过调试器访问。



我知道在某些情况下调试器可能会出现故障。我从来没有遇到过清理解决方案的问题,但是一些开发人员报告称清洁解决方案在某些情况下并没有真正清理它。在Wost情况下,您可以关闭Visual Studio并删除除真实源代码之外的所有文件。实际上,您只需删除构建创建的obj子目录。此外,所有那些* .ncb,* .user和* .suo文件都不是源代码的一部分,可以删除。然后断点也将被删除,您可以稍后添加它们。源文件是Visual Studio的解决方案资源管理器树视图中显示的文件,没有别的。



-SA

Hello friends,

I wrote a code in which i am continuously looping through a set of functions let us say around 2-3 functions. Its a while loop, which executes continuously.

Now to check the execution of a particular function i applied break point at that function. I noticed that the debugger breaks on that function, but never executes it.

I also applied a few break points inside the function on which i applied the break point. But the debugger never broke at them. Which means that the compiler never went inside that function.

I will replicate the scenario :

class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                fun1();
                fun2();
                fun3();

            }


        }

        static void fun1()
        {
            Console.WriteLine("hello1");
        }

        static void fun2()
        {
            Console.WriteLine("hello2");

        }

        static void fun3()
        {
            Console.WriteLine("hello3");

        }


    }






any suggestions? i mean to say that, what can be the possible reason behind it? I also wrote a thread.sleep(200); instruction. But that dint work too.

If i restart my application( without making any changes i.e i dont remove the break point), it works fine.

Thanks a ton,
Rahul

解决方案

Thank you for clarification. At this time, your sample code is correct; and all parts of it should be reachable with the debugger.

I know that in some cases the debugger can make glitches. I never had a problem with cleaning the solution, but some developers reported that "Clean Solution" did not really clean it in some cases. In wost case, you can close Visual Studio and remove all files except real source code. Practically, you just remove the "obj" sub-directory created by the build. Also, all those *.ncb, *.user and *.suo files are not part of the source code, can be deleted. Then the breakpoints will be removed, too, you can add them later. Source files are those presented in the Solution Explorer tree view of Visual Studio, nothing else.

—SA


这篇关于即使调试器在该函数上中断,函数也不会执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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