From 91c91df9b76aba42b163277162e7eace277d1bde Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Mon, 16 Jun 2025 13:30:16 +0200 Subject: [PATCH] Fixes possible crash on assembly fetching for third party assemblies --- lib/core/tools/Test-IcingaAddTypeExist.psm1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/core/tools/Test-IcingaAddTypeExist.psm1 b/lib/core/tools/Test-IcingaAddTypeExist.psm1 index e1a6bb7..ce471ba 100644 --- a/lib/core/tools/Test-IcingaAddTypeExist.psm1 +++ b/lib/core/tools/Test-IcingaAddTypeExist.psm1 @@ -31,12 +31,15 @@ function Test-IcingaAddTypeExist() } foreach ($entry in [System.AppDomain]::CurrentDomain.GetAssemblies()) { - if ($entry.GetTypes() -Match $Type) { - $LoadedTypes.Add($Type, $TRUE); + try { + if ($entry.GetTypes() -Match $Type) { + $LoadedTypes.Add($Type, $TRUE); - Set-IcingaPrivateEnvironmentVariable -Name 'AddTypeFunctions' -Value $LoadedTypes; + Set-IcingaPrivateEnvironmentVariable -Name 'AddTypeFunctions' -Value $LoadedTypes; - return $TRUE; + return $TRUE; + } + } catch { } }