Browse Source

Ignore exceptions while reading debug symbols. Closes #169.

pull/172/head
Daniel Grunwald 15 years ago
parent
commit
553ea3f698
  1. 24
      ILSpy/LoadedAssembly.cs

24
ILSpy/LoadedAssembly.cs

@ -88,24 +88,28 @@ namespace ICSharpCode.ILSpy
// runs on background thread // runs on background thread
ReaderParameters p = new ReaderParameters(); ReaderParameters p = new ReaderParameters();
p.AssemblyResolver = new MyAssemblyResolver(this); p.AssemblyResolver = new MyAssemblyResolver(this);
try { AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, p);
if (DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols) { if (DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols) {
SetSymbolSettings(p); try {
LoadSymbols(asm.MainModule);
} catch (IOException) {
} catch (UnauthorizedAccessException) {
} catch (InvalidOperationException) {
// ignore any errors during symbol loading
} }
return AssemblyDefinition.ReadAssembly(fileName, p);
} finally {
if (p.SymbolStream != null)
p.SymbolStream.Dispose();
} }
return asm;
} }
private void SetSymbolSettings(ReaderParameters p) private void LoadSymbols(ModuleDefinition module)
{ {
// search for pdb in same directory as dll // search for pdb in same directory as dll
string pdbName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb"); string pdbName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb");
if (File.Exists(pdbName)) { if (File.Exists(pdbName)) {
p.ReadSymbols = true; using (Stream s = File.OpenRead(pdbName)) {
p.SymbolStream = File.OpenRead(pdbName); module.ReadSymbols(new Mono.Cecil.Pdb.PdbReaderProvider().GetSymbolReader(module, s));
}
return;
} }
// TODO: use symbol cache, get symbols from microsoft // TODO: use symbol cache, get symbols from microsoft

Loading…
Cancel
Save