From 2cea00c9428d9a2335cf3ffaaf41c746fa0ebb0b Mon Sep 17 00:00:00 2001 From: Peter Kirmeier Date: Mon, 26 Apr 2021 19:41:04 +0200 Subject: [PATCH] Using cached icon instead of loading it multiple times from resources This prevents a potential crash if lots of icons cannot be loaded (see https://stackoverflow.com/questions/36446000/system-reflection-targetinvocationexception-in-resources-designer-vb ) Fixes #159 --- DataClasses/RowData.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index dfadd0b..5c3fde6 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -22,6 +22,7 @@ namespace SystemTrayMenu.DataClasses internal class RowData : IDisposable { + private static readonly Icon White50PercentageIcon = Properties.Resources.WhiteTransparency; private static DateTime contextMenuClosed; private string workingDirectory; private string arguments; @@ -76,14 +77,14 @@ namespace SystemTrayMenu.DataClasses if (icon == null) { - icon = Properties.Resources.WhiteTransparency; + icon = White50PercentageIcon; } if (HiddenEntry) { row[0] = IconReader.AddIconOverlay( data.icon, - Properties.Resources.WhiteTransparency); + White50PercentageIcon); } else {