C# 符号文件未加载用于在 Visual Studio 2012 中调试自定义项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18109575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 11:18:50  来源:igfitidea点击:

Symbol file not loading for debugging custom project in Visual Studio 2012

c#.netvisual-studiovisual-studio-2012msbuild

提问by Nanhydrin

I have a large solution in Visual Studio 2012 which consists of executables and class library projects. When debugging the application the breakpoints in one particular class library project are not being hit.

我在 Visual Studio 2012 中有一个大型解决方案,它由可执行文件和类库项目组成。在调试应用程序时,没有命中一个特定类库项目中的断点。

I looked at the Debug> Windows> Moduleswindow to check the status of the symbols for that project and it says "Cannot find or open the PDB file".
It also says "No"under the "User Code"column.
I notice that there are a few other of the custom projects in the solution that are showing "No" in that column and their symbols are also failing to load. Anything with a "Yes" under "User code" seems to have had it's pdb loaded no problem. But I'm not sure if this is relevant.

我查看了Debug> Windows> Modules窗口以检查该项目的符号状态,它显示“无法找到或打开 PDB 文件”
它还在“用户代码”列下显示“否”。 我注意到解决方案中还有其他一些自定义项目在该列中显示“否”,并且它们的符号也无法加载。“用户代码”下带有“是”的任何内容似乎都已加载 pdb 没有问题。但我不确定这是否相关。

I have used dumpbin /headerson the dll and the path for the pdb file is present and correct.

我在 dll 上使用了dumpbin /headers并且 pdb 文件的路径存在且正确。

The module is definitely not in the exclude list for the symbol loading.

该模块绝对不在符号加载的排除列表中。

I have also tried right clicking on the entry in the modules window, selecting "Load symbols"and navigating to the path given in the dll header. When I select the pdb it says "A matching symbol file was not found in this folder".

我还尝试右键单击模块窗口中的条目,选择“加载符号”并导航到 dll 标头中给出的路径。当我选择 pdb 时,它说“在此文件夹中找不到匹配的符号文件”

I get this after I have deleted these folders and files, cleaned the solution, closed it and rebuilt the whole thing. The pdb was definitely built at the same time as the dll in question.

在我删除这些文件夹和文件、清理解决方案、关闭它并重建整个过程后,我得到了这个。pdb 肯定是与有问题的 dll 同时构建的。

So clearly the problem is the "cannot open the pdb" portion of the error message.

很明显,问题是错误消息的“无法打开 pdb”部分。

I have tried this on 2 computers and both are exhibiting the same behaviour.

我已经在 2 台计算机上尝试过这个,并且都表现出相同的行为。

Can anyone offer any suggestions on where to go from here, and perhaps why on earth the built pdb corresponding to the dll won't load for it?

任何人都可以提供有关从这里去哪里的任何建议,也许为什么与 dll 对应的内置 pdb 不会加载它?

采纳答案by Nanhydrin

I tried a few tools to check if the pdb and the dll actually matched, and using chkmatchI could see that the GUIDs in the dll being run and the pdb in the obj folder didn't match.

我尝试了一些工具来检查 pdb 和 dll 是否实际匹配,并且使用chkmatch我可以看到正在运行的 dll 中的 GUID 和 obj 文件夹中的 pdb 不匹配。

So it turns out that although the dll and pdb in the project's obj folder are a match, the dll that was actually getting copied to the application's destination folder by a post-build event was the old dll from the previous build.

所以事实证明,虽然项目 obj 文件夹中的 dll 和 pdb 是匹配的,但实际上被构建后事件复制到应用程序目标文件夹的 dll 是来自先前构建的旧 dll。

The post-build event was running before that particular project had built, or at least finished building, and was copying in the existing dll from the bin which was subsequently overwritten by the continuing build.

构建后事件在该特定项目构建之前运行,或者至少在构建完成之前运行,并且正在从 bin 复制现有的 dll,随后被继续构建覆盖。

I have resolved the problem by editing the project dependencies for the solution and ensuring that the project with the post-build event is dependent on the project that wasn't loading, and now the pdb loads during debug.

我已经通过编辑解决方案的项目依赖项并确保具有构建后事件的项目依赖于未加载的项目来解决该问题,现在 pdb 在调试期间加载。

回答by Pompair

For me it helped to use chkmatch tool and then just close and open visual studio, make clean and rebuild. Now my pdb gets also loaded. You can make sure it does, as Nanhydrin pointed out, from Debug -> Windows -> Modules - this view is only accessible during debugging.

对我来说,它有助于使用 chkmatch 工具,然后关闭并打开 Visual Studio,进行清理和重建。现在我的 pdb 也被加载了。正如 Nanhydrin 指出的那样,您可以确保它确实如此,从 Debug -> Windows -> Modules - 此视图只能在调试期间访问。

回答by MacGyver

I simply deleted bin and obj folder from the startup project folder and rebuild the solution.

我只是从启动项目文件夹中删除了 bin 和 obj 文件夹并重建了解决方案。

回答by Mohamed Badr

For me I just deleted the project from IIS and created it again and it works fine

对我来说,我刚刚从 IIS 中删除了该项目并再次创建它,它工作正常

回答by justcoding121

In my case older version of referenced dll was in my GAC. Cleared it out, and it worked.

在我的情况下,引用的 dll 的旧版本在我的 GAC 中。清除了它,它起作用了。

回答by Md Hasan Ibrahim

Deleted the project from solution and added it again to the solution worked for me. :)

从解决方案中删除了项目并将其再次添加到对我有用的解决方案中。:)

回答by Paddy

Bit late to the party here - just in case this is helpful.

在这里参加派对有点晚了 - 以防万一这是有帮助的。

We have a couple of separate websites (in different solutions in Visual Studio). On initial load of one of the sites, we were making a call to the other site which would return an image.

我们有几个单独的网站(在 Visual Studio 的不同解决方案中)。在其中一个站点的初始加载时,我们正在调用另一个站点,该站点将返回图像。

Both of these sites referenced a common DLL, but while working on one site, had not realised that the other site had been left in a 'Release' build - after the site loaded, the offending DLL was rebuilt, but without symbols.

这两个站点都引用了一个公共 DLL,但是在一个站点上工作时,并没有意识到另一个站点被保留在“发布”版本中 - 在站点加载后,有问题的 DLL 被重建,但没有符号。

Kudos to Nanhydrin for both mentioning the modules debug window (very helpful) and for putting me on the right track with the post build event.

感谢 Nanhydrin 提到模块调试窗口(非常有用)和让我在后期构建事件中走上正轨。

回答by Boyan P

Answer from another thread that worked for me: https://stackoverflow.com/a/28476665/5969306
- In Visual Studio: Project Properties -> Build -> Advanced button -> Debug info drop-down and make sure the value is not “none”.

来自另一个对我有用的线程的回答:https: //stackoverflow.com/a/28476665/5969306
- 在 Visual Studio 中:项目属性 -> 构建 -> 高级按钮 -> 调试信息下拉菜单并确保该值不是“没有任何”。

回答by SimpsOff

Reminder: Put the project into "Debug" configuration... for those like me who forget and feel silly.

提醒:将项目放入“调试”配置中...对于像我这样忘记并感到愚蠢的人。

回答by chris31389

I found that the project I was receiving the message about, was being optimized when built.

我发现我收到消息的项目在构建时正在优化。

I went into the projects properties, Compile Tab, Advanced Compile Options... and unchecked the Enable Optimizationscheckbox

我进入项目属性,编译选项卡,高级编译选项...并取消选中Enable Optimizations复选框

Deselect Enable Optimizations

取消选择启用优化