This problem began after the last-but-one VS2019 update but I can't specifically say (yet) that the update was the cause of the problem as I made some code changes after the update. This is a C++ add-on module (dll) for a mixed-mode (C++/dotNet) commercial product, so I don't have access to the original .exe code or .pdb files and I have to state that the product has never given trouble in itself in ten years of working with it. Importantly, it was all working until that update.
这个问题是在VS2019的倒数第二次更新后出现的,但我还不能明确地说这次更新是问题的原因,因为我在更新后做了一些代码更改。这是一个混合模式(C++/DotNet)商业产品的C++附加模块(DLL),因此我无法访问原始的.exe代码或.pdb文件,我必须声明,在使用它的十年中,该产品本身从未出现过问题。重要的是,在那次更新之前,一切都在运行。
Environment:
环境:
- Visual Studio 2019 v4.8.09032
- Windows 11 fully patched
- Windows 11 optional updates (where required) fully patched
Current debug setup:
当前调试设置:
Configuration Properties
配置属性
Debugging | Local Windows Debugger
调试|本地Windows调试器
C/C++ | General | Program Database
C/C++|通用|程序数据库
C/C++ | Code Generation | Multithreaded Debug Dll
C/C++|代码生成|多线程调试DLL
Linker | Debugging | Generate Debug Information
链接器|调试|生成调试信息
Tools | Options | Debugging | disabled 'Enable Edit and Continue'
工具|选项|调试|禁用“启用编辑并继续”
No pre- or post- build steps.
没有构建前或构建后步骤。
What I have tried:
我尝试了以下几点:
- Rolled back the code changes
- Checked Configuration Manager (x64 Debug Active)
- Various combinations of the options available under C/C++ | Code Generation | Multithreaded Debug Dll and Linker | Debugging | Generate Debug Information
- Tools | Options | Debugging | checked and unchecked 'Enable Just My Code'
- Tools | Options | Debugging | checked and unchecked 'Require source files to exactly match the original version'
- Deleted the .vs folder and rebuilt it
- Deleted the entire Solution and copied back in an archived and known working Solution from four months ago (the Solution and the source files are in separate folders)
After each recompile I have manually deleted the .dll, .pdb, .lib and .exp files before copying in the new ones to ensure that no files are stale.
每次重新编译后,我都会手动删除.dll、.pdb、.lib和.exp文件,然后再复制新文件,以确保文件不会过时。
Additional information:
补充资料:
- The dll no longer shows up in Debug | Windows | Modules so I can't force a .pdb load (I'm guessing that fixing this might be the answer to the problem)
- The 'Dependencies' program says that there are no missing linkages
Interestingly (or not so!) I have found that I get the same error on every single project that I have tested in trying to debug the problem. This includes creating new projects and simply running older archived projects where the code has not been touched for months.
有趣的是(或者不是这样!)我发现,在我测试的每个项目上,在尝试调试问题时都会遇到相同的错误。这包括创建新项目和简单地运行旧的归档项目,在这些项目中代码已经几个月没有被接触过了。
Updating to VS2022 is not currently an option but will have to follow once the current module is fully debugged in VS2019. The C++ version in use is ISO 17; I cannot upgrade the ISO version because of legacy C code that is no longer supported in ISO 20 and I cannot downgrade it because of some C++ updates in use that came with ISO 17.
更新到VS 2022目前不是一个选项,但一旦当前模块在VS 2019中完全调试完毕,就必须进行更新。使用的C++版本是ISO 17;我不能升级ISO版本,因为ISO 20不再支持旧的C代码,我不能降级它,因为ISO 17附带的一些C++更新正在使用。
更多回答
It won't work as long as the DLL doesn't show up in the Modules list. Most obvious setting that's relevant is Project > Properties > Debugging > "Debugger Type" = Mixed. If the main startup project is C# then use Project > Properties > Debug > "Enable native code debugging" ticked. Double-check that the test code actually tries to load the DLL (notification in the Output window) and that you see it back in the Modules list.
只要DLL没有出现在模块列表中,它就不会工作。最明显的相关设置是项目>属性>调试>“调试器类型”=MIXED。如果主启动项目是C#,则使用勾选的Project>Properties>Debug>“Enable本地代码调试”。仔细检查测试代码是否实际尝试加载DLL(输出窗口中的通知),以及您是否在模块列表中看到它。
I've tried Mixed (dotnet Framework and dotNet Core) but to no avail. It was set to Auto. The project dll is not loading in the Output window but another dll of mine that the project dll makes a call to is being loaded. The Output window also states that the parent .exe is CLR 4.0.30319. Just to state the obvious for clarity, the project dll is being called by the parent .exe, otherwise I wouldn't see anything onscreen.
我尝试了混合(DotNet框架和DotNet Core),但没有效果。它被设置为自动。项目DLL没有加载到输出窗口中,但项目DLL调用的我的另一个DLL正在加载。输出窗口还显示父.exe为CLR 4.0.30319。为了清楚起见,项目DLL是由父.exe调用的,否则我在屏幕上看不到任何东西。
I still have this problem if anyone has any further suggestions. What I have done in the meantime is to uninstall both VS2019 and VS2022 and reinstall VS2019 only without any extensions. Unfortunately the problem still exists. It is doubly annoying in that dotNet debugging works perfectly.
如果有人有任何进一步的建议,我仍然有这个问题。在此期间,我所做的是卸载VS2019和VS2022,并且只在没有任何扩展的情况下重新安装VS2019。不幸的是,这个问题仍然存在。更令人讨厌的是,DotNet调试可以完美地工作。
I have no idea why the following worked, but it did.
我不知道为什么下面的方法有效,但确实有效。
- Under Project | Properties | Configuration Properties | Debugging set Command to the path to the executable (i.e. it's hard-coded and not $(TargetPath))
- Rebuild the project
- Copied the dll, pdb, exp and lib files to the folder where the executable expects to find them
- Hit the Local Windows Debugger green arrow instead of Debug | Attach To Process
The Debug | Window | Modules suddenly filled up with additional dlls - including mine - and the breakpoint was immediately hit.
调试|窗口|模块中突然充满了额外的dll-包括我的-断点立即命中。
更多回答
我是一名优秀的程序员,十分优秀!