diff --git a/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs b/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs index 54313faa7..7199be31a 100644 --- a/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs +++ b/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs @@ -124,9 +124,6 @@ public bool AddToCache (AssemblyDefinition assembly) public virtual AssemblyDefinition? Load (string fileName, bool forceLoad = false) { - if (!File.Exists (fileName)) - return null; - AssemblyDefinition? assembly = null; var name = Path.GetFileNameWithoutExtension (fileName); if (!forceLoad && cache.TryGetValue (name, out assembly)) @@ -134,6 +131,9 @@ public bool AddToCache (AssemblyDefinition assembly) try { assembly = ReadAssembly (fileName); + } catch (Exception e) when (e is FileNotFoundException || e is DirectoryNotFoundException) { + // These are ok, we can return null + return null; } catch (Exception e) { Diagnostic.Error (9, e, Localization.Resources.CecilResolver_XA0009, fileName); } @@ -144,8 +144,8 @@ public bool AddToCache (AssemblyDefinition assembly) protected virtual AssemblyDefinition ReadAssembly (string file) { bool haveDebugSymbols = loadDebugSymbols && - (File.Exists (file + ".mdb") || - File.Exists (Path.ChangeExtension (file, ".pdb"))); + (File.Exists (Path.ChangeExtension (file, ".pdb")) || + File.Exists (file + ".mdb")); var reader_parameters = new ReaderParameters () { ApplyWindowsRuntimeProjections = loadReaderParameters.ApplyWindowsRuntimeProjections, AssemblyResolver = this,