diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.netcore.cs index e7d04e44bc..e9a73c5704 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.netcore.cs @@ -25,7 +25,7 @@ internal static void ApplyContextSwitches(IAppContextSwitchOverridesSection appC SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName); if (appContextSwitches != null) { - ApplySwitchValues(appContextSwitches.Value?.Split('=', ';')); + ApplySwitchValues(appContextSwitches.Value?.Trim(';')?.Split('=', ';')); } SqlClientEventSource.Log.TryTraceEvent(" Exit point.", TypeName, methodName); @@ -39,7 +39,7 @@ private static bool ApplySwitchValues(string[] switches) if (switches == null || switches.Length == 0 || switches.Length % 2 == 1) { return false; } - for (int i = 0; i < switches.Length / 2; i++) + for (int i = 0; i < switches.Length; i += 2) { try {