问题
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