How do I get the line number and path of a method from a pdb using .Net?

左心房为你撑大大i 提交于 2019-12-11 17:31:47

问题


Given an assembly and its pdb, how do I get the line number and path to a method using .Net?


回答1:


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 call findChildren() passing it the SymTagFunction enumeration which of type SymTagEnum. You will then need to enumerate over them and use an IDiaSession, previously made to get the global IDiaSymbol, instance to find the correct source and line number.



来源:https://stackoverflow.com/questions/3697547/how-do-i-get-the-line-number-and-path-of-a-method-from-a-pdb-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!