Repository navigation
Closed
Description
- .NET Core Version: 3.0.0-preview6-27720-09
- Windows version: (
winver) 1903 - Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description:
When pointing to a https source on MediaPlayer, you'll get a NullReferenceException. This doesn't occur with http.
However this doesn't happen in click-once deployments, because that's what it uses to check if the secure connection is used or not, but since most scenarios aren't click-once this fails because
null is returned.
It's clear the code here never assumed this wouldn't be used in a click-once scenario (appDeploymentUri us null so crashes on line 987):
wpf/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs
Lines 979 to 992 in 9c3bd0e
| // access is allowed in the following cases (only 1 & 2 require elevation): | |
| // 1) to any HTTPS media if app is NOT coming from HTTPS | |
| // 2) to URI in the current directory of the fusion cache | |
| // 3) to site of origin media | |
| if (SecurityHelper.AreStringTypesEqual(uriToOpen.Scheme, Uri.UriSchemeHttps)) | |
| { | |
| // target is HTTPS. Then, elevate ONLY if we are NOT coming from HTTPS (=XDomain HTTPS app to HTTPS media disallowed) | |
| Uri appDeploymentUri = SecurityHelper.ExtractUriForClickOnceDeployedApp(); | |
| if (!SecurityHelper.AreStringTypesEqual(appDeploymentUri.Scheme, Uri.UriSchemeHttps)) | |
| { | |
| new WebPermission(NetworkAccess.Connect, BindUriHelper.UriToString(uriToOpen)).Assert(); | |
| elevated = true; | |
| } | |
| } |
StackTrace:
``` at System.Windows.Media.MediaPlayerState.OpenMedia(Uri source) at System.Windows.Media.MediaPlayerState.SetSource(Uri source) at System.Windows.Media.MediaPlayerState.Open(Uri source) at System.Windows.Media.MediaPlayer.Open(Uri source) at test.MainWindow.Button_Click(Object sender, RoutedEventArgs e) in e:\GitHub\dotnet\test\MainWindow.xaml.cs:line 33 at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at test.App.Main() ```Expected behavior:
Audio plays
Minimal repro:
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("https://www.thesoundarchive.com/email/youGotmail.wav"));Remove "s" from https, and the audio will play fine.
Reacted by Peter Foot, Steven Brix, 房鹤· and IgorTimofeev
Metadata
Metadata
Assignees
Labels
No labels

Activity
jviolas commentedon Jun 20, 2019
It's not only audio files, it's true for video too. And it's the same with
System.Windows.Controls.MediaElementcontrol.This crashes has been around for years in WPF...
stevenbrix commentedon Jun 22, 2019
@grubioe i don't recall the discussion we had around this one, but i'm wondering if we should revisit our previous decision and consider fixing this for 3.0? it seems a little backwards that we are forcing http connections instead of https
stevenbrix commentedon Jun 22, 2019
This may sound like a naive question, but do most apps use their own deployment mechanism? If so, why would they not use ClickOnce? Does you know if this repros when using MSIX? We should probably review any code that makes assumptions about ClickOnce and see if they still hold true with MSIX.
weltkante commentedon Jun 24, 2019
As far as I know most people are either using MSIX directly or 3rd party installers (usually based on MSIX). I rarely see ClickOnce, probably because its not very flexible when you have applications which are more than a single exe + dll bundle (like having optional installable features, start menu integration, registry keys, multiple exe files, etc.)
dotMorten commentedon Jun 24, 2019
PR linked above also fixes this issue, so this issue should soon (finally) be taken care off
dotMorten commentedon Jun 27, 2019
Pulled latest code in master and tried out #969. I can confirm this fixes this issue.
eFloh commentedon Jan 11, 2022
this is still open in .NET 4.8, fixed only in .NET Core.
Minimal Repro: MedieElement fails on HTTPS
Minimal Repro: MedieElement fails on HTTPS
vishalmsft commentedon Jan 13, 2022
@eFloh This is not planned to be taken in 4.8. Thank you for bringing this up.