From 2c3d0b3fbceb57623422ad91212852c52c0338a3 Mon Sep 17 00:00:00 2001 From: Vatsan Madhavan Date: Thu, 27 Feb 2020 14:09:55 -0800 Subject: [PATCH] Temporary workaround for https://github.com/dotnet/runtime/issues/32929; do not merge into master. --- .../System/Windows/Media/MediaContext.cs | 6 +++-- .../Microsoft/Win32/CommonDialog.cs | 22 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs index 832a8ec06e9..84c5985e1f4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs @@ -194,8 +194,10 @@ private static int FindNextPrime(int number) /// when inside a SCM service. /// internal static bool ShouldRenderEvenWhenNoDisplayDevicesAreAvailable { get; } = - !Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService... - !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override + // Temporary workaround for https://github.com/dotnet/runtime/issues/32929 + // Do not merge into master + // !Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService... + // !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable; // ELSE do not render by default, allow ShouldRender AppContext override diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs index e159c1060df..1d3fbd8be6b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs @@ -72,10 +72,13 @@ public virtual Nullable ShowDialog() // Don't allow file dialogs to be shown if not in interactive mode // (for example, if we're running as a service) - if (!Environment.UserInteractive) - { - throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive)); - } + + // Temporary workaround for https://github.com/dotnet/runtime/issues/32929 + // Do not merge into master + // if (!Environment.UserInteractive) + // { + // throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive)); + // } // Call GetActiveWindow to retrieve the window handle to the active window // attached to the calling thread's message queue. We'll set the owner of @@ -149,10 +152,13 @@ public Nullable ShowDialog(Window owner) // Don't allow file dialogs to be shown if not in interactive mode // (for example, if we're running as a service) - if (!Environment.UserInteractive) - { - throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive)); - } + + // Temporary workaround for https://github.com/dotnet/runtime/issues/32929 + // Do not merge into master + // if (!Environment.UserInteractive) + // { + // throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive)); + // } // Get the handle of the owner window using WindowInteropHelper. IntPtr hwndOwner = (new WindowInteropHelper(owner)).CriticalHandle;