From 1a0f5a88b7a5b3618e603e955da2b4e8122f233c Mon Sep 17 00:00:00 2001 From: BDisp Date: Sun, 31 Aug 2025 16:46:11 +0100 Subject: [PATCH] Fixes #4228. Init crashes if there are assemblies that have load issues (#4230) --- Terminal.Gui/App/Application.Initialization.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Terminal.Gui/App/Application.Initialization.cs b/Terminal.Gui/App/Application.Initialization.cs index b5c9b1d1b..c688783e4 100644 --- a/Terminal.Gui/App/Application.Initialization.cs +++ b/Terminal.Gui/App/Application.Initialization.cs @@ -212,14 +212,15 @@ public static partial class Application // Initialization (Init/Shutdown) // use reflection to get the list of drivers List driverTypes = new (); - foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) + // Only inspect the IConsoleDriver assembly + var asm = typeof (IConsoleDriver).Assembly; + + foreach (Type? type in asm.GetTypes ()) { - foreach (Type? type in asm.GetTypes ()) + if (typeof (IConsoleDriver).IsAssignableFrom (type) && + type is { IsAbstract: false, IsClass: true }) { - if (typeof (IConsoleDriver).IsAssignableFrom (type) && !type.IsAbstract && type.IsClass) - { - driverTypes.Add (type); - } + driverTypes.Add (type); } }