Merge pull request 'fix(billing): tolerate ReflectionTypeLoadException during init' (#19) from fix/billing-init-reflection into release/1.0.6

Reviewed-on: #19
This commit is contained in:
Paul Schneider 2026-08-16 16:43:09 +01:00
commit f74577f80a

View file

@ -70,7 +70,27 @@ namespace Yavsc.Helpers
foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies()) foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies())
{ {
foreach (var c in a.GetTypes()) Type[] types;
try
{
types = a.GetTypes();
}
catch (System.Reflection.ReflectionTypeLoadException rtle)
{
// Some referenced types failed to load; keep the
// ones that did and skip the rest so a flaky
// dependency in one assembly does not break
// billing initialization for every other assembly.
types = rtle.Types.Where(t => t != null).ToArray();
}
catch
{
// Assembly itself cannot be loaded (FileNotFoundException
// on a referenced assembly, etc.). Skip it entirely.
continue;
}
foreach (var c in types)
{ {
if (c.IsClass && !c.IsAbstract && if (c.IsClass && !c.IsAbstract &&
c.GetInterface(nameof(IUserSettings)) != null) c.GetInterface(nameof(IUserSettings)) != null)