From fc22f6a4a024b7e02de8f53f35d50c1517afd9fe Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Sat, 29 Jun 2019 08:29:20 -0600 Subject: [PATCH] Fixes #919 --- src/UniversalDashboard/Cmdlets/StartDashboardCommand.cs | 6 ++++-- src/UniversalDashboard/Cmdlets/StartRestApiCommand.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/UniversalDashboard/Cmdlets/StartDashboardCommand.cs b/src/UniversalDashboard/Cmdlets/StartDashboardCommand.cs index a9eaefd0..a1424413 100644 --- a/src/UniversalDashboard/Cmdlets/StartDashboardCommand.cs +++ b/src/UniversalDashboard/Cmdlets/StartDashboardCommand.cs @@ -65,8 +65,10 @@ protected override void EndProcessing() if (Force) { var existingServer = Server.Servers.FirstOrDefault(m => m.Port == Port || m.Name == m.Name); - existingServer.Stop(); - Server.Servers.Remove(existingServer); + if (existingServer != null) { + existingServer.Stop(); + Server.Servers.Remove(existingServer); + } } // Cache dashboard diff --git a/src/UniversalDashboard/Cmdlets/StartRestApiCommand.cs b/src/UniversalDashboard/Cmdlets/StartRestApiCommand.cs index e62382f1..d9c2c235 100644 --- a/src/UniversalDashboard/Cmdlets/StartRestApiCommand.cs +++ b/src/UniversalDashboard/Cmdlets/StartRestApiCommand.cs @@ -58,8 +58,10 @@ protected override void EndProcessing() if (Force) { var existingServer = Server.Servers.FirstOrDefault(m => m.Port == Port || m.Name == m.Name); - existingServer.Stop(); - Server.Servers.Remove(existingServer); + if (existingServer != null) { + existingServer.Stop(); + Server.Servers.Remove(existingServer); + } } var server = new Server(Name, MyInvocation.ScriptName, AutoReload, Host, Port);