From c9ba627df529c4e5a8dfa16e2a3174e4530f5c28 Mon Sep 17 00:00:00 2001 From: codeimp Date: Sat, 10 Jan 2009 22:34:36 +0000 Subject: [PATCH] added a check to handle invalid DLLs in the Plugins directory --- Source/Plugins/Plugin.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Plugins/Plugin.cs b/Source/Plugins/Plugin.cs index 2dc7cbfb..c5b6e9d3 100644 --- a/Source/Plugins/Plugin.cs +++ b/Source/Plugins/Plugin.cs @@ -69,10 +69,18 @@ namespace CodeImp.DoomBuilder.Plugins // Initialize name = Path.GetFileNameWithoutExtension(filename); General.WriteLogLine("Loading plugin '" + name + "' from '" + Path.GetFileName(filename) + "'..."); - - // Load assembly - asm = Assembly.LoadFile(filename); + try + { + // Load assembly + asm = Assembly.LoadFile(filename); + } + catch(Exception) + { + General.WriteLogLine("ERROR: Could not load plugin '" + name + "', the DLL file could not be read!"); + throw new InvalidProgramException(); + } + // Find the class that inherits from Plugin Type t = FindSingleClass(typeof(Plug)); if(t != null)