//
        // Retrieve the source fileName, line number, and column
        //
        private static void TryGetSourceLineInfo(IDiaSession session, int rva, out string fileName, out int lineNumber, out int columnNumber)
        {
            fileName     = null;
            lineNumber   = 0;
            columnNumber = 0;
            IDiaEnumLineNumbers lineNumbers;
            int hr = session.FindLinesByRVA(rva, 1, out lineNumbers);

            if (hr == S_OK)
            {
                int numLineNumbers;
                hr = lineNumbers.Count(out numLineNumbers);
                if (hr == S_OK && numLineNumbers > 0)
                {
                    IDiaLineNumber ln;
                    hr = lineNumbers.Item(0, out ln);
                    if (hr == S_OK)
                    {
                        IDiaSourceFile sourceFile;
                        hr = ln.SourceFile(out sourceFile);
                        if (hr == S_OK)
                        {
                            hr = sourceFile.FileName(out fileName);
                            if (hr == S_OK)
                            {
                                hr = ln.LineNumber(out lineNumber);
                                if (hr == S_OK)
                                {
                                    hr = ln.ColumnNumber(out columnNumber);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 //
 // Retrieve the source fileName, line number, and column
 //
 private static void TryGetSourceLineInfo(IDiaSession session, int rva, out string fileName, out int lineNumber, out int columnNumber)
 {
     fileName = null;
     lineNumber = 0;
     columnNumber = 0;
     IDiaEnumLineNumbers lineNumbers;
     int hr = session.FindLinesByRVA(rva, 1, out lineNumbers);
     if (hr == S_OK)
     {
         int numLineNumbers;
         hr = lineNumbers.Count(out numLineNumbers);
         if (hr == S_OK && numLineNumbers > 0)
         {
             IDiaLineNumber ln;
             hr = lineNumbers.Item(0, out ln);
             if (hr == S_OK)
             {
                 IDiaSourceFile sourceFile;
                 hr = ln.SourceFile(out sourceFile);
                 if (hr == S_OK)
                 {
                     hr = sourceFile.FileName(out fileName);
                     if (hr == S_OK)
                     {
                         hr = ln.LineNumber(out lineNumber);
                         if (hr == S_OK)
                         {
                             hr = ln.ColumnNumber(out columnNumber);
                         }
                     }
                 }
             }
         }
     }
 }