Catches exception (with notification) while trying to get corrupt duplicated env...
authorMaryam Ariyan <maryam.ariyan@microsoft.com>
Thu, 1 Nov 2018 21:19:20 +0000 (14:19 -0700)
committerGitHub <noreply@github.com>
Thu, 1 Nov 2018 21:19:20 +0000 (14:19 -0700)
Throw and catch intentionally with non-fatal notification about corrupted environment block

Commit migrated from https://github.com/dotnet/corefx/commit/a0e8f0b1783d182c150610e615ff7ca554b4e46c

src/libraries/System.Runtime.Extensions/src/System/Environment.cs

index 448b434..f8922da 100644 (file)
@@ -4,6 +4,7 @@
 
 using System.Collections;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using Internal.Runtime.Augments;
@@ -44,7 +45,14 @@ namespace System
             Hashtable hashTable = new Hashtable();
             foreach (KeyValuePair<string, string> pair in pairs)
             {
-                hashTable.Add(pair.Key, pair.Value);
+                try 
+                {
+                    hashTable.Add(pair.Key, pair.Value);                 
+                }
+                catch (ArgumentException)
+                {
+                    // Throw and catch intentionally to provide non-fatal notification about corrupted environment block
+                }
             }
             return hashTable;
         }