From 9c7b8a511fb74aa4b1994b257c9122829e1f0696 Mon Sep 17 00:00:00 2001 From: Marcin Szeniak <14913904+Klocman@users.noreply.github.com> Date: Sat, 4 Mar 2023 15:06:08 +0100 Subject: [PATCH] Fix startup crash on systems with no accessible network interfaces --- source/BulkCrapUninstaller/Program.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source/BulkCrapUninstaller/Program.cs b/source/BulkCrapUninstaller/Program.cs index 3cd1b210..65330295 100644 --- a/source/BulkCrapUninstaller/Program.cs +++ b/source/BulkCrapUninstaller/Program.cs @@ -145,8 +145,20 @@ private static ulong GetUniqueUserId() { // Get an ID that is unlikely to be duplicate but that should always return the same on current pc var windowsIdentity = WindowsIdentity.GetCurrent(); - var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); - var idStr = windowsIdentity.User?.Value + string.Join("", windowsIdentity.Claims.Select(x => x.Value).Concat(networkInterfaces.Select(x => x.GetPhysicalAddress().ToString()))); + + string networkIdentity; + try + { + var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); + networkIdentity = string.Join("", networkInterfaces.Select(x => x.GetPhysicalAddress().ToString())); + } + catch (Exception e) + { + Console.WriteLine(e); + networkIdentity = e.ToString(); + } + + var idStr = windowsIdentity.User?.Value + string.Join("", windowsIdentity.Claims.Select(x => x.Value)) + networkIdentity; return UninstallerRatingManager.Utils.StableHash(idStr); }