From ebaec9c319480d09438aed87dcb5e1502dfda240 Mon Sep 17 00:00:00 2001 From: Kevin Cunnane Date: Wed, 11 Jul 2018 09:27:41 -0700 Subject: [PATCH] Fix GUID parse error breaking some on-prem connections (#654) * Fix GUID parse error breaking on-prem connections - Fixes https://github.com/Microsoft/sqlopsstudio/issues/1896 - Verified this is only used in retry logic on Azure, so the fact it's failing on-prem isn't relevant. It's still unclear why in some cases the session ID is non-null but not a GUID. * Added back logging if parse of the GUID fails --- .../Connection/ReliableConnection/ReliableSqlConnection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ReliableConnection/ReliableSqlConnection.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ReliableConnection/ReliableSqlConnection.cs index b427f5b7..058c0c92 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ReliableConnection/ReliableSqlConnection.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ReliableConnection/ReliableSqlConnection.cs @@ -434,12 +434,15 @@ SET NUMERIC_ROUNDABORT OFF;"; if (DBNull.Value != result) { string sessionId = (string)command.ExecuteScalar(); - _azureSessionId = new Guid(sessionId); + if (!Guid.TryParse(sessionId, out _azureSessionId)) + { + Logger.Write(LogLevel.Error, Resources.UnableToRetrieveAzureSessionId); + } } } } } - catch (SqlException exception) + catch (Exception exception) { Logger.Write(LogLevel.Error, Resources.UnableToRetrieveAzureSessionId + exception.ToString()); }