From 4aaed08955cba4e08e9022bba9ca35b6a3f575e5 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Jun 2021 09:59:24 -0700 Subject: [PATCH] Ignore all exceptions when disposing an instance of a subsystem implementation (#15511) --- .../engine/Subsystem/SubsystemManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs index 8764cf83cf..d211cb532a 100644 --- a/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs +++ b/src/System.Management.Automation/engine/Subsystem/SubsystemManager.cs @@ -280,7 +280,14 @@ namespace System.Management.Automation.Subsystem ISubsystem impl = subsystemInfo.UnregisterImplementation(id); if (impl is IDisposable disposable) { - disposable.Dispose(); + try + { + disposable.Dispose(); + } + catch + { + // It's OK to ignore all exceptions when disposing the object. + } } }