简体   繁体   English

Visual Studio 跳过代码行

[英]Visual Studio skips lines of code

I have been working on a program in which I use the EnumWindows function to detect active Windows and save their handles in a list.我一直在开发一个程序,在该程序中我使用 EnumWindows 函数来检测活动的 Windows 并将它们的句柄保存在列表中。 Now, everytime I run what I have so far the debugger just skips the line with the EnumWindows function without returning an error.现在,每次我运行我到目前为止所拥有的东西时,调试器都会跳过带有 EnumWindows 函数的行而不会返回错误。

Is there something wrong with my code?我的代码有问题吗? Or do I have to get an additional library to access this function?或者我是否必须获得额外的库才能访问此功能? Hope someone knows how to fix this Here is the code of the class which contains EnumWindows:希望有人知道如何解决这个问题这是包含 EnumWindows 的类的代码:

Center :: Center(int initInterval) : interval(initInterval)
{
    detectWindows();
}

int Center :: getInterval()
{
    return interval;
}
void Center :: setInterval(int intrvl)
{
    interval = intrvl;
}

void Center :: initializeDisplays()
{

}

void Center :: detectWindows()
{
    EnumWindows(detectWindowsProc, (LPARAM)&windowList);  //Debugger skips this line
}

Code shouldn't be just skipped, typically this is a sign of your source/exe/ and PDB files being out of sync.不应跳过代码,通常这是源/exe/ 和 PDB 文件不同步的标志。 Clean your project and try again (remove all.exe, obj, pdbs) and ensure you are doing a debug build.清理您的项目并重试(删除 all.exe、obj、pdbs)并确保您正在进行调试构建。

Check Debug->Windows->Modules.检查调试->Windows->模块。 I just tested a similar scenario, worked fine on breakpoints.我刚刚测试了一个类似的场景,在断点上运行良好。 Check the timestamp of your PDB as shown here to ensure its up to date如此处所示检查您的 PDB 的时间戳,以确保它是最新的在此处输入图像描述

What do you mean by 'skips the line'? “跳过线路”是什么意思? The debugger will step over it, execute it, but will not be able to step in to it because you have no debug information available for the windows functions.调试器将跨过它,执行它,但将无法进入它,因为您没有可用于 windows 函数的调试信息。 Normally if you put a breakpoint in your detectWindowsProc that breakpoint should be hit.通常,如果您在detectWindowsProc中放置一个断点,则应该命中该断点。 Provided there are windows to enumerate, EnumWindows has some strange quirks, see MSDN and comments there for more info: EnumWindows function如果有要枚举的窗口, EnumWindows有一些奇怪的怪癖,请参阅 MSDN 和那里的评论以获取更多信息: EnumWindows 函数

I also had face this issue.我也遇到过这个问题。 For me.pdb file was not in sync with.dll I updated the dll and pdb and issue was fixed.对于 me.pdb 文件与 .dll 不同步,我更新了 dll 和 pdb,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM