From 40aef0c403a55da5bfd170b7f60b560b923e8ba1 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 9 Sep 2020 14:52:03 -0700 Subject: [PATCH] Ignore IOException when setting OutputEncoding See #47571 --- .../Host/Interactive/Core/InteractiveHost.Service.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Interactive/Host/Interactive/Core/InteractiveHost.Service.cs b/src/Interactive/Host/Interactive/Core/InteractiveHost.Service.cs index 249c781d33d..77dcf20798e 100644 --- a/src/Interactive/Host/Interactive/Core/InteractiveHost.Service.cs +++ b/src/Interactive/Host/Interactive/Core/InteractiveHost.Service.cs @@ -18,6 +18,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Scripting; using Microsoft.CodeAnalysis.Scripting.Hosting; using Roslyn.Utilities; @@ -140,7 +141,15 @@ private Service(Func, object> invokeOnMainThread) _lastTask = Task.FromResult(initialState); - Console.OutputEncoding = Encoding.UTF8; + try + { + Console.OutputEncoding = Encoding.UTF8; + } + catch (IOException ex) when (FatalError.ReportWithoutCrash(ex)) + { + // Ignore this exception + // https://github.com/dotnet/roslyn/issues/47571 + } // We want to be sure to delete the shadow-copied files when the process goes away. Frankly // there's nothing we can do if the process is forcefully quit or goes down in a completely -- GitLab