diff --git a/src/DynamoCoreWpf/Services/IconServices.cs b/src/DynamoCoreWpf/Services/IconServices.cs index d9b658dbf84..a36ea1c92d5 100644 --- a/src/DynamoCoreWpf/Services/IconServices.cs +++ b/src/DynamoCoreWpf/Services/IconServices.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -67,8 +67,9 @@ internal IconWarehouse(Assembly resAssembly) internal ImageSource LoadIconInternal(string iconKey) { - if (cachedIcons.ContainsKey(iconKey)) - return cachedIcons[iconKey]; + ImageSource icon; + if (cachedIcons.TryGetValue(iconKey, out icon)) + return icon; if (resourceAssembly == null) { diff --git a/src/LibraryViewExtensionWebView2/Handlers/IconResourceProvider.cs b/src/LibraryViewExtensionWebView2/Handlers/IconResourceProvider.cs index 84b1010940d..ac59207d806 100644 --- a/src/LibraryViewExtensionWebView2/Handlers/IconResourceProvider.cs +++ b/src/LibraryViewExtensionWebView2/Handlers/IconResourceProvider.cs @@ -80,9 +80,10 @@ public string GetResourceAsString(string url, out string extension) url = url?.Replace("about:", string.Empty); } - if (!String.IsNullOrEmpty(url) && urlToBase64DataCache.ContainsKey(url)) + Tuple tmpUrl = null; + if (!String.IsNullOrEmpty(url) && urlToBase64DataCache.TryGetValue(url, out tmpUrl)) { - var cachedData = urlToBase64DataCache[url]; + var cachedData = tmpUrl; extension = cachedData.Item2; return cachedData.Item1; }