Visual Studio如何知道源文件是否与原始版本匹配? [英] How does Visual Studio know if the source file matches the original version?

查看:237
本文介绍了Visual Studio如何知道源文件是否与原始版本匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我弄清楚了如何使用GUID将.NET程序集.dll文件映射到.pdb(博客)。当我调试一个程序集并询问源代码时,如果我导航到一个文件,则可能会告诉我源代码与原始代码不同。它怎么知道的?我期望.pdb文件包含每个文件的校验和,但似乎没有。我发现转储调试信息的最佳工具是 dia2dump 。 C ++ .pdb文件具有MD5条目,但C#.pdb文件没有。

I figured out how a .NET assembly .dll file maps to a .pdb using a GUID (blog). When I debug into an assembly and it asks for the source code, if I navigate to a file, it may tell me that the source code is different from the original. How does it know this? I was expecting the .pdb file to contain a checksum for each file, but it doesn't appear to. The best tool I found to dump the debug information is dia2dump. The C++ .pdb files had MD5 entries, but the C# .pdb files did not.

C ++转储

dia2dump -f dia2dump.pdb> dia2dump.pdb.files.txt

C#dump

dia2dump -f Autofac.pdb> Autofac.pdb.files.txt

dia2dump -all Autofac.pdb> Autofac.pdb.all.txt

全部转储中是否缺少某些内容?

Is there something I missed in the "all" dump?

必须使用校验和。如果我在Module.cs中更改单个字符,则会得到:

It has got to be using a checksum. If I change a single character in Module.cs, I get:

在哪里可以找到.pdb中引用的源文件的校验和?

Where do I find the checksum for a source file referenced in a .pdb?

推荐答案

每个源文件的MD5校验和都存储在.pdb文件中。如果您对上面的问题您是否仍然希望调试器使用它?回答否,它将打印出所要查找的校验和:

An MD5 checksum is stored in the .pdb file for each source file. If you answer "No" to the question above "Would you like the debugger to use it anyway?", it prints out the checksum it was looking for:

使用十六进制编辑器,您可以看到它肯定在.pdb中。我的下一个任务是弄清楚如何以编程方式访问它。对于.pdb文件,我希望它返回所有源文件名及其MD5校验和。

Using a hex editor, you can see it is definitely in the .pdb. My next task is to figure out how to get access to it programatically. For a .pdb file, I want it to return all source file names and their MD5 checksums.

这篇关于Visual Studio如何知道源文件是否与原始版本匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆