diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs index b6ca3549e5..293a5a683b 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs @@ -111,9 +111,17 @@ public Task NotifyDataAvailable() /// public void Dispose() { - EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer."); - _reader.Dispose(); - _writer.Dispose(); + try + { + EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer."); + _reader.Dispose(); + _writer.Dispose(); + } + catch (ObjectDisposedException) + { + // We don't own the underlying stream lifecycle so it's possible that it's already disposed. + } + GC.SuppressFinalize(this); } }