diff --git a/mRemoteV1/Connection/Protocol/ProtocolBase.cs b/mRemoteV1/Connection/Protocol/ProtocolBase.cs index 0d5878f6..b358c47d 100644 --- a/mRemoteV1/Connection/Protocol/ProtocolBase.cs +++ b/mRemoteV1/Connection/Protocol/ProtocolBase.cs @@ -335,7 +335,8 @@ namespace mRemoteNG.Connection.Protocol { if (!disposing) return; - tmrReconnect?.Dispose(); + if(tmrReconnect != null) + tmrReconnect.Dispose(); } public void Dispose() diff --git a/mRemoteV1/Security/EncryptedSecureString.cs b/mRemoteV1/Security/EncryptedSecureString.cs index 1bf59ea9..66319d6f 100644 --- a/mRemoteV1/Security/EncryptedSecureString.cs +++ b/mRemoteV1/Security/EncryptedSecureString.cs @@ -61,8 +61,11 @@ namespace mRemoteNG.Security { if (!disposing) return; - _machineKey?.Dispose(); - _secureString?.Dispose(); + if(_machineKey != null) + _machineKey.Dispose(); + + if(_secureString != null) + _secureString.Dispose(); } public void Dispose() diff --git a/mRemoteV1/Tools/ProcessController.cs b/mRemoteV1/Tools/ProcessController.cs index 7107d392..dbea0eb6 100644 --- a/mRemoteV1/Tools/ProcessController.cs +++ b/mRemoteV1/Tools/ProcessController.cs @@ -168,7 +168,8 @@ namespace mRemoteNG.Tools { if (!disposing) return; - Process?.Dispose(); + if(Process != null) + Process.Dispose(); Handle = IntPtr.Zero; } diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index dfd8f21d..df8f78cc 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -69,8 +69,11 @@ namespace mRemoteNG.UI.Controls { if (disposing) { - components?.Dispose(); - _statusImageList?.Dispose(); + if(components != null) + components.Dispose(); + + if(_statusImageList != null) + _statusImageList.Dispose(); } base.Dispose(disposing); diff --git a/mRemoteV1/UI/Controls/MultiSshToolStrip.cs b/mRemoteV1/UI/Controls/MultiSshToolStrip.cs index 96ade99c..aa547d52 100644 --- a/mRemoteV1/UI/Controls/MultiSshToolStrip.cs +++ b/mRemoteV1/UI/Controls/MultiSshToolStrip.cs @@ -63,7 +63,8 @@ namespace mRemoteNG.UI.Controls { if (disposing) { - components?.Dispose(); + if(components != null) + components.Dispose(); } base.Dispose(disposing); diff --git a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs index 4f5a270a..8f9f5e9a 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs @@ -1,4 +1,4 @@ -using TextBox = mRemoteNG.UI.Forms.TextBox; +using TextBox = mRemoteNG.UI.Forms.TextBox; namespace mRemoteNG.UI.Forms { @@ -12,9 +12,13 @@ namespace mRemoteNG.UI.Forms { try { - if (disposing && components != null) + if (disposing) { - components.Dispose(); + if(components != null) + components.Dispose(); + + if(_password != null) + _password.Dispose(); } } finally diff --git a/mRemoteV1/UI/Forms/frmMain.Designer.cs b/mRemoteV1/UI/Forms/frmMain.Designer.cs index 7fb17c4a..dc8c75a7 100644 --- a/mRemoteV1/UI/Forms/frmMain.Designer.cs +++ b/mRemoteV1/UI/Forms/frmMain.Designer.cs @@ -1,4 +1,4 @@ -namespace mRemoteNG.UI.Forms +namespace mRemoteNG.UI.Forms { public partial class FrmMain : System.Windows.Forms.Form { @@ -9,10 +9,15 @@ namespace mRemoteNG.UI.Forms { try { - if (disposing && components != null) + if (disposing) { - components.Dispose(); - } + if(components != null) + components.Dispose(); + + if(_screenSystemMenu != null) + _screenSystemMenu.Dispose(); + + } } finally { diff --git a/mRemoteV1/UI/Menu/ScreenSelectionSystemMenu.cs b/mRemoteV1/UI/Menu/ScreenSelectionSystemMenu.cs index cca0057a..f91a4379 100644 --- a/mRemoteV1/UI/Menu/ScreenSelectionSystemMenu.cs +++ b/mRemoteV1/UI/Menu/ScreenSelectionSystemMenu.cs @@ -60,7 +60,8 @@ namespace mRemoteNG.UI.Menu { if (!disposing) return; - _systemMenu?.Dispose(); + if(_systemMenu != null) + _systemMenu.Dispose(); } public void Dispose() diff --git a/mRemoteV1/UI/Tabs/DockPaneStripNG.cs b/mRemoteV1/UI/Tabs/DockPaneStripNG.cs index af5fcd30..4e234dfe 100644 --- a/mRemoteV1/UI/Tabs/DockPaneStripNG.cs +++ b/mRemoteV1/UI/Tabs/DockPaneStripNG.cs @@ -357,16 +357,21 @@ namespace mRemoteNG.UI.Tabs ResumeLayout(); } + // This seems like a bogus warning - suppressing since Components is being disposed... + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "k__BackingField")] protected override void Dispose(bool disposing) { if (disposing) { - Components.Dispose(); + if(Components != null) + Components.Dispose(); + if (m_boldFont != null) { m_boldFont.Dispose(); m_boldFont = null; } + } base.Dispose(disposing);