added a check to handle invalid DLLs in the Plugins directory

This commit is contained in:
codeimp 2009-01-10 22:34:36 +00:00
parent 5adaf2ee4b
commit c9ba627df5

View file

@ -69,10 +69,18 @@ namespace CodeImp.DoomBuilder.Plugins
// Initialize // Initialize
name = Path.GetFileNameWithoutExtension(filename); name = Path.GetFileNameWithoutExtension(filename);
General.WriteLogLine("Loading plugin '" + name + "' from '" + Path.GetFileName(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 // Find the class that inherits from Plugin
Type t = FindSingleClass(typeof(Plug)); Type t = FindSingleClass(typeof(Plug));
if(t != null) if(t != null)