如何使用 .Net 从 pdb 获取方法的行号和路径?
给定一个程序集及其 pdb,如何使用 .Net 获取方法的行号和路径?
Given an assembly and its pdb, how do I get the line number and path to a method using .Net?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用DIA SDK。 Microsoft 没有针对它的托管界面,但 使用之前曾在 StackOverflow 上询问过 C# 中的 DIA。
如果您打算首先在本机中尝试,您可以通过获取相关 PDB 的
IDiaSymbol
实例来获取相关信息,这称为 '全局范围'。完成后,您将调用findChildren()
< /a> 向其传递SymTagFunction
枚举,其类型为SymTagEnum
。然后,您需要枚举它们并使用先前用于获取全局IDiaSymbol
实例的IDiaSession
来查找正确的源代码和行号。You will need to use the DIA SDK. Microsoft does not have a managed interface for it, but using DIA in C# has been asked on StackOverflow before.
If you are going to try it out in native first you can get the information in question by getting the
IDiaSymbol
instance for the PDB in question, this is called the 'global scope'. Once you have that you will callfindChildren()
passing it theSymTagFunction
enumeration which of typeSymTagEnum
. You will then need to enumerate over them and use anIDiaSession
, previously made to get the globalIDiaSymbol
, instance to find the correct source and line number.