/// <summary> /// Looks through the configured symbol paths to find a PDB symbol /// file matching specified name, GUID and age parameters. /// </summary> /// <param name="pdbFileName"></param> /// <param name="guid"></param> /// <param name="age"></param> /// <returns></returns> /// <remarks> /// Note how we don't have to have a module loaded to find its PDB, /// we just look for a PDB file using name, GUID and age. These are /// the parameters that can be extracted from module's PE header, /// in the Debug Directory section. /// </remarks> public string FindPdbFile(string pdbFileName, Guid guid, int age) { DbgHelp.SymSetOptions(DbgHelp.SYMOPT_DEBUG); var hProcess = new IntPtr(1); #if TARGET_NET_20 var searchPath = string.Join(";", this.SymbolPaths.ToArray()); #else var searchPath = string.Join(";", this.SymbolPaths); #endif DbgHelp.SymInitialize(hProcess, searchPath, false); var filePath = new StringBuilder(256); var guidHandle = GCHandle.Alloc(guid, GCHandleType.Pinned); try { if (!DbgHelp.SymFindFileInPath(hProcess, null, pdbFileName, guidHandle.AddrOfPinnedObject(), (uint)age, 0, DbgHelp.SSRVOPT_GUIDPTR, filePath, null, IntPtr.Zero)) { return(null); } } finally { guidHandle.Free(); DbgHelp.SymCleanup(hProcess); } return(filePath.ToString()); }