简体   繁体   English

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

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

I have a large solution in Visual Studio 2012 which consists of executables and class library projects.我在 Visual Studio 2012 中有一个大型解决方案,它由可执行文件和类库项目组成。 When debugging the application the breakpoints in one particular class library project are not being hit.在调试应用程序时,没有命中一个特定类库项目中的断点。

I looked at the Debug> Windows> Modules window to check the status of the symbols for that project and it says "Cannot find or open the PDB file" .我查看了Debug> Windows> Modules窗口以检查该项目的符号状态,它显示“无法找到或打开 PDB 文件”
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. “用户代码”下带有“是”的任何内容似乎都加载了 pdb 没有问题。 But I'm not sure if this is relevant.但我不确定这是否相关。

I have used dumpbin /headers on 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.我还尝试右键单击模块窗口中的条目,选择“加载符号”并导航到 dll 标头中给出的路径。 When I select the pdb it says "A matching symbol file was not found in this folder" .当我选择 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 不会加载它?

I tried a few tools to check if the pdb and the dll actually matched, and using chkmatch I 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 在调试期间加载。

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

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

For me it helped to use chkmatch tool and then just close and open visual studio, make clean and rebuild.对我来说,它有助于使用 chkmatch 工具,然后关闭并打开 Visual Studio,进行清理和重建。 Now my pdb gets also loaded.现在我的 pdb 也被加载了。 You can make sure it does, as Nanhydrin pointed out, from Debug -> Windows -> Modules - this view is only accessible during debugging.正如 Nanhydrin 指出的那样,您可以确保它确实如此,从 Debug -> Windows -> Modules - 此视图只能在调试期间访问。

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 Optimizations checkbox我进入项目属性,编译选项卡,高级编译选项...并取消选中Enable Optimizations复选框

取消选择启用优化

In my case older version of referenced dll was in my GAC.在我的情况下,引用的 dll 的旧版本在我的 GAC 中。 Cleared it out, and it worked.清除了它,它起作用了。

In my case there was a check mark on Enable Just My Code in Tools>>Options>>Debugging>>General .在我的情况下,在Tools>>Options>>Debugging>>General Enable Just My Code上有一个复选标记。

I unchecked it and it worked.我取消选中它并且它起作用了。

Example Image示例图像

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

Deleted the project from solution and added it again to the solution worked for me.从解决方案中删除了项目并将其再次添加到对我有用的解决方案中。 :) :)

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).我们有几个单独的网站(在 Visual Studio 的不同解决方案中)。 On initial load of one of the sites, we were making a call to the other site which would return an image.在其中一个站点的初始加载时,我们正在调用另一个站点,该站点将返回图像。

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 提到模块调试窗口(非常有用)和让我在后期构建事件中走上正轨。

Answer from another thread that worked for me: https://stackoverflow.com/a/28476665/5969306来自另一个对我有用的线程的回答: 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”. - 在 Visual Studio 中:项目属性 -> 构建 -> 高级按钮 -> 调试信息下拉菜单并确保该值不是“无”。

I just had this issue and thought I would put my fix here, as it my help others (maybe even myself again?!) in the future...我刚刚遇到了这个问题,并认为我会将我的修复程序放在这里,因为它可以帮助其他人(甚至可能是我自己?!)在未来......

Make sure that when you are attaching to the process on the remote server, that the "Attach to" is set to确保当您附加到远程服务器上的进程时,“附加到”设置为

Automatically determine the type of code to debug自动确定要调试的代码类型

To do this, When the server qualifier has been provided and a list of processes is visible, click the "Select" button next to the "Attach to" input.为此,当提供了服务器限定符并且进程列表可见时,单击“附加到”输入旁边的“选择”按钮。

图 1 Then, select "Automatically determine the type of code to debug" and OK out of the screen, then attach.然后,从屏幕中选择“自动确定要调试的代码类型”和“确定”,然后附加。

图 2
This fixed the issue for me, at least.这至少为我解决了这个问题。

I had a line like this in my debug window:我的调试窗口中有这样一行:

Symbols for the module 'MyModule.dll' were not loaded.未加载模块“MyModule.dll”的符号。

I removed the 'Optimize code' option in Project properties -> Build.我删除了项目属性 -> 构建中的“优化代码”选项。 And the error disappeared.并且错误消失了。

This issue may be due to wrong reference of dlls used in project.此问题可能是由于项目中使用的 dll 引用错误所致。

Delete obj and bin folders in current project and build project again.删除当前项目中的objbin文件夹并重新构建项目。

Check for permission to ASP.NET Temporary folder:检查 ASP.NET 临时文件夹的权限:

"c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"

User of application pool has to have the rights to subfolder with ASP.NET files, something like:应用程序池的用户必须有权访问包含 ASP.NET 文件的子文件夹,例如:

root\60039743\c28e12ee
  1. Check options from this answer: https://stackoverflow.com/a/38377530/6911991检查此答案中的选项: https : //stackoverflow.com/a/38377530/6911991
  2. Click Advanced and check that Debugging Information is set to FULL单击Advanced并检查Debugging Information是否设置为 FULL
    高级选项卡截图
  3. Check Run Configuration in all projects in the solution检查解决方案中所有项目中的运行配置

I had this issue , tried all the other solutions (it took 2 days !! I'm crying... !TWO DAYS!) But finally I realized that my file was registered in GAC, I removed it and the problem was resolved.我遇到了这个问题,尝试了所有其他解决方案(花了 2 天!我在哭……!两天!)但最后我意识到我的文件已在 GAC 中注册,我将其删除并解决了问题。

At the command prompt, type the following command:在命令提示符下,键入以下命令:

gacutil –u <assembly name>

How to: Remove an Assembly from the Global Assembly Cache 如何:从全局程序集缓存中删除程序集

请检查您的 dll 的依赖关系,如果您添加到解决方案中,这可能会导致加载符号失败。

I resolved this issue by disabling 'Use Managed Compatibility Mode' in the Debug->Options menu:我通过在Debug->Options菜单中禁用“Use Managed Compatibility Mode”解决了这个问题:

在此处输入图片说明

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

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