Skip to content

Commit

Permalink
Misc: Handle FileLoadException when loading plugin dlls
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Oct 9, 2021
1 parent 4f4fda7 commit 2860b51
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion osu!StreamCompanion/Code/Core/DiContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ private static List<Assembly> GetAssemblies(IEnumerable<string> fileList, ILogge
var assemblies = new List<Assembly>();
foreach (var file in fileList)
{
var fileName = Path.GetFileNameWithoutExtension(file);
try
{
var assemblyName = new AssemblyName(Path.GetFileNameWithoutExtension(file));
var assemblyName = new AssemblyName(fileName);
assemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyName(assemblyName));
}
catch (BadImageFormatException e)
Expand Down Expand Up @@ -176,6 +177,13 @@ private static List<Assembly> GetAssemblies(IEnumerable<string> fileList, ILogge
+ "Please reinstall StreamCompanion.", "StreamCompanion - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
Program.SafeQuit();
}
catch (FileLoadException e)
{
MessageBox.Show($"Plugin \"{fileName}\" could not get loaded. StreamCompanion will continue to work, however, some features might be missing." +
Environment.NewLine + Environment.NewLine + "Error:" +
Environment.NewLine + e,
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

return assemblies;
Expand Down

0 comments on commit 2860b51

Please sign in to comment.