visual-studio Visual Studio bin\debug 文件夹中的 PDB 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/132719/
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
PDB files in Visual Studio bin\debug folders
提问by Joel in G?
I have a Visual Studio (2008) solution consisting of several projects, not all in the same namespace. When I build the solution, all the DLL files used by the top level project, TopProject, are copied into the TopProject\bin\debugfolder. However, the corresponding .pdb files are only copied for some of the other projects. This is a pain, for example when using NDepend.
我有一个由多个项目组成的 Visual Studio (2008) 解决方案,但并非都在同一个命名空间中。当我构建解决方案时,顶级项目TopProject使用的所有 DLL 文件都被复制到TopProject\bin\debug文件夹中。但是,相应的 .pdb 文件仅为其他一些项目复制。这很痛苦,例如在使用NDepend 时。
How does Visual Studio decide which .pdb files to copy into higher level bin\debug folders? How can I get Visual Studio to copy the others too?
Visual Studio 如何决定将哪些 .pdb 文件复制到更高级别的 bin\debug 文件夹中?我怎样才能让 Visual Studio 也复制其他人?
References are as follows: all the DLL files are copied to a central location, without their PDB files. TopProjectonlyhas references to these copied DLL files; the DLL files themselves, however, evidently know where their PDB files are, and (most of them) get copied to the debugfolder correctly.
参考如下:所有DLL文件都复制到一个中央位置,没有它们的PDB文件。TopProject只引用了这些复制的 DLL 文件;然而,DLL 文件本身显然知道它们的 PDB 文件在哪里,并且(其中大部分)被debug正确复制到文件夹中。
回答by John Rudy
From MSDN:
从MSDN:
A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program. A PDB file is created when you compile a C/C++ program with /ZI or /Zi or a Visual Basic/C#/JScript .NET program with /debug.
程序数据库 (PDB) 文件包含调试和项目状态信息,允许增量链接程序的调试配置。当您使用 /ZI 或 /Zi 编译 C/C++ 程序或使用 /debug 编译 Visual Basic/C#/JScript .NET 程序时,会创建 PDB 文件。
So it looks like the "issue" here (for lack of a better word) is that some of your DLLs are being built in debug mode (and hence emitting PDB files), and some are being built in release mode (hence not emitting PDB files). If that's the case, it should be easy to fix -- go into each project and update its build settings. This would be the default scenario, if you haven't done any tweaking of command line options.
所以看起来这里的“问题”(因为没有更好的词)是你的一些 DLL 是在调试模式下构建的(因此发出 PDB 文件),而有些是在发布模式下构建的(因此不发出 PDB文件)。如果是这种情况,应该很容易修复——进入每个项目并更新其构建设置。如果您没有对命令行选项进行任何调整,这将是默认情况。
However, it will get trickier if that isn't the case. Maybe you're all in release or debug mode. Now you need to look at the command line compile options (specified in the project properties) for each project. Update them to /debug accordingly if you want the debugger, or remove it if you don't.
但是,如果不是这种情况,情况会变得更加棘手。也许你们都处于发布或调试模式。现在您需要查看每个项目的命令行编译选项(在项目属性中指定)。如果您需要调试器,请相应地将它们更新到 /debug,如果不需要,请将其删除。
Edit in Response to Edit
编辑回应编辑
Yes, the DLL files "know" that they have PDB files, and have paths to them, but that doesn't mean too much. Copying just DLL files to a given directory, as others have mentioned, won't clear this issue up. You need the PDB files as well.
是的,DLL 文件“知道”它们有 PDB 文件,并且有它们的路径,但这并不意味着太多。正如其他人提到的那样,仅将 DLL 文件复制到给定目录并不能解决此问题。您还需要 PDB 文件。
Copying individual files in Windows, with the exception of certain "bundle"-type files (I don't know Microsoft's term for this, but "complete HTML packages" are the concept) doesn't copy associated files. DLL files aren't assembled in the "bundle" way, so copying them leaves their PDB file behind.
在 Windows 中复制单个文件,除了某些“捆绑”类型的文件(我不知道微软对此的术语,但“完整的 HTML 包”是概念)不会复制相关文件。DLL 文件不是以“捆绑”方式组装的,因此复制它们会将其 PDB 文件留在后面。
I'd say the only answer you're going to have is to update your process for getting the DLL files to those central locations, and include the PDB files ... I'd love to be proven wrong on that, though!
我想说你唯一的答案是更新你的过程以将 DLL 文件获取到那些中心位置,并包含 PDB 文件......不过,我很想在这方面被证明是错误的!
回答by Code Trawler
Check when you clean the solution, that it is actually cleaned.
清洁溶液时,请检查它是否确实已清洁。
I've seen Visual Studio leave files hanging around in bin\debugdirectories even after cleaning. Delete the bin\debugdirectory on all of your projects and rebuild.
我已经看到 Visual Studiobin\debug即使在清理后也会将文件留在目录中。删除bin\debug所有项目上的目录并重建。
回答by Dean Hill
As other posts have said, you may have a compiler/corruption issue.
正如其他帖子所说,您可能有编译器/损坏问题。
But, as Will said, if the PDB files are being created, but not showing up where you want them, create a post-build step. Here is the post-build step I define for every project in my solution. It makes sure all output files are copied into a common directory.
但是,正如 Will 所说,如果正在创建 PDB 文件,但没有显示在您想要的位置,请创建一个构建后步骤。这是我为解决方案中的每个项目定义的构建后步骤。它确保所有输出文件都复制到一个公共目录中。
If your project file is in \SolutionDir\ProjDir, then the first line of the post-build step will copy the output files to \Solution\Bin\Release or \Solution\Bin\Debug. The second line copies the PDB file if this is a debug build. I don't copy the PDB file for release builds.
如果您的项目文件在 \SolutionDir\ProjDir 中,那么构建后步骤的第一行会将输出文件复制到 \Solution\Bin\Release 或 \Solution\Bin\Debug。如果这是一个调试版本,第二行复制 PDB 文件。我不复制发布版本的 PDB 文件。
So, \SolutionDir\Bin now contains all your output files in one location.
因此,\SolutionDir\Bin 现在在一个位置包含所有输出文件。
xcopy /r /y $(TargetPath) $(ProjectDir)..$(OutDir)
if $(ConfigurationName) == Debug xcopy /r /y $(TargetDir)$(TargetName).pdb $(ProjectDir)..$(OutDir)
回答by Dean Hill
First off, never assume anything. Clean the solution, rebuild it in debug mode, and check to see if all PDB files are created. If not, that's your problem.
首先,永远不要假设任何事情。清理解决方案,在调试模式下重建它,并检查是否创建了所有 PDB 文件。如果没有,那是你的问题。
If they are created, and they're not all getting copied, you can get around this by creating a post build event that manually copies the PDB files to the desired locations. This is just a workaround, of course.
如果它们被创建,并且它们并没有全部被复制,您可以通过创建一个后期构建事件来解决这个问题,该事件手动将 PDB 文件复制到所需的位置。当然,这只是一种解决方法。
The only other thing I can think of is that your solution file has become corrupt. You can open your .sln as an XML file and examine the contents. Check the configuration for the projects that are acting as expected and compare them to those that aren't. If you don't see anything, you have to repeat this at the project level. Compare working .csproj (or whatever) project files and the non-working ones.
我唯一能想到的另一件事是您的解决方案文件已损坏。您可以将 .sln 作为 XML 文件打开并检查其内容。检查按预期运行的项目的配置,并将它们与未按预期运行的项目进行比较。如果您没有看到任何内容,则必须在项目级别重复此操作。比较工作 .csproj(或其他)项目文件和非工作文件。
Edit in response to edit:
编辑以响应编辑:
If you're just manually copying stuff around, then manually copy the PDF files as well. DLL files shouldn't "know" anything about PDB files, I believe. Just stick them in the destination directory and go have a cup of coffee. Relax.
如果您只是手动复制内容,那么也手动复制 PDF 文件。我相信 DLL 文件不应该“知道”有关 PDB 文件的任何信息。只需将它们放在目标目录中,然后去喝杯咖啡。放松。

