Browse Source

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
shortcuts
Daniel Grunwald 20 years ago
parent
commit
05aa4c4885
  1. 12
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs
  2. 16
      src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

12
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionLoader.cs

@ -27,7 +27,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -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 @@ -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;

16
src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

@ -172,9 +172,13 @@ namespace ICSharpCode.Core @@ -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<string, string, string>)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 @@ -187,6 +191,16 @@ namespace ICSharpCode.Core
}
}
delegate void Action3<A, B, C>(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;

Loading…
Cancel
Save