From 05aa4c4885b43d14c0bfc3c52b4fe9d28a489d78 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 23 Feb 2006 17:35:28 +0000 Subject: [PATCH] Fixed exception when loading a project when a referenced library was missing dependencies. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1176 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/Dom/ReflectionLayer/ReflectionLoader.cs | 12 ++++++++---- .../ParserService/ProjectContentRegistry.cs | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs index 2d1af33506..09896f72df 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs @@ -27,7 +27,11 @@ namespace ICSharpCode.SharpDevelop.Dom return null; return DomPersistence.SaveProjectContent(content); } catch (Exception ex) { - LoggingService.Error(ex); + if (ex is FileLoadException) { + LoggingService.Info(ex); + } else { + LoggingService.Error(ex); + } throw; } } @@ -48,10 +52,10 @@ namespace ICSharpCode.SharpDevelop.Dom if (assembly != null) return new ReflectionProjectContent(assembly); else - return null; - } catch (BadImageFormatException) { + throw new FileLoadException("Assembly not found."); + } catch (BadImageFormatException ex) { LoggingService.Warn("BadImageFormat: " + include); - return null; + throw new FileLoadException(ex.Message, ex); } finally { AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= AssemblyResolve; lookupDirectory = null; diff --git a/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs b/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs index 94587d508b..11dc3fa775 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs @@ -172,9 +172,13 @@ namespace ICSharpCode.Core object o = domain.CreateInstanceAndUnwrap(typeof(ReflectionLoader).Assembly.FullName, typeof(ReflectionLoader).FullName); ReflectionLoader loader = (ReflectionLoader)o; database = loader.LoadAndCreateDatabase(filename, include); + } catch (FileLoadException e) { + database = null; + WorkbenchSingleton.SafeThreadAsyncCall((Action3)ShowErrorMessage, + new object[] { filename, include, e.Message }); } catch (Exception e) { database = null; - MessageService.ShowError(e, "Error loading " + include + " from " + filename); + MessageService.ShowError(e, "Error loading code-completion information for " + include + " from " + filename); } finally { AppDomain.Unload(domain); } @@ -187,6 +191,16 @@ namespace ICSharpCode.Core } } + delegate void Action3(A a, B b, C c); + + static void ShowErrorMessage(string filename, string include, string message) + { + WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront(); + TaskService.BuildMessageViewCategory.AppendText("Error loading code-completion information for " + + include + " from " + filename + + ":\r\n" + message + "\r\n"); + } + public static Assembly MscorlibAssembly { get { return typeof(object).Assembly;