Open
Description
Description
I'm using a custom control which inherits from MediaPlayerElement in my application. When creating an instance of my control, the application to throwing a NullReferenceException
.
Steps To Reproduce
- Create an UWP + .Net 9 application
- Create a custom
MediaPlayerElement
control like:
public partial class CustomMediaPlayerElement : MediaPlayerElement
{
public static readonly DependencyProperty IsPresenterEnabledProperty = DependencyProperty.Register(
nameof(IsPresenterEnabled),
typeof(bool),
typeof(CustomMediaPlayerElement),
new PropertyMetadata(true));
public bool IsPresenterEnabled
{
get => (bool)GetValue(IsPresenterEnabledProperty);
set => SetValue(IsPresenterEnabledProperty, value);
}
}
- Add this control to the main page
<StackPanel>
<local:CustomMediaPlayerElement IsPresenterEnabled="True" />
</StackPanel>
- Run the application
The application is throwing a NullReferenceException
in:
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Controls.MediaPlayerElement.System.Runtime.InteropServices.ICustomQueryInterface.GetInterface(ref System.Guid iid, out nint ppv) Line 297 C#
System.Private.CoreLib.dll!System.Runtime.InteropServices.ComWrappers.CallICustomQueryInterface(object customQueryInterfaceMaybe, ref System.Guid iid, out nint ppObject) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Controls.MediaPlayerElement._IMediaPlayerElementFactoryMethods.CreateInstance(WinRT.IObjectReference _obj, object baseInterface, out nint innerInterface) Line 35 C#
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Controls.MediaPlayerElement.MediaPlayerElement() Line 218 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.CustomMediaPlayerElement.CustomMediaPlayerElement() Unknown
UWPAndDotNetNine.dll!UWPAndDotNetNine.UWPAndDotNetNine_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_CustomMediaPlayerElement() Line 253 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.UWPAndDotNetNine_XamlTypeInfo.XamlUserType.ActivateInstance() Line 462 C#
Microsoft.Windows.UI.Xaml.dll!ABI.Windows.UI.Xaml.Markup.IXamlType.Do_Abi_ActivateInstance_12(nint thisPtr, nint* result) Line 155 C#
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.Windows.UI.Xaml.dll!ABI.Windows.UI.Xaml.IApplicationStaticsMethods.LoadComponent(WinRT.IObjectReference _obj, object component, System.Uri resourceLocator, Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation componentResourceLocation) Line 71 C#
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Application.LoadComponent(object component, System.Uri resourceLocator, Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation componentResourceLocation) Line 320 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.MainPage.InitializeComponent() Line 37 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.MainPage.MainPage() Line 25 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.UWPAndDotNetNine_XamlTypeInfo.XamlTypeInfoProvider.Activate_3_MainPage() Line 254 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.UWPAndDotNetNine_XamlTypeInfo.XamlUserType.ActivateInstance() Line 462 C#
Microsoft.Windows.UI.Xaml.dll!ABI.Windows.UI.Xaml.Markup.IXamlType.Do_Abi_ActivateInstance_12(nint thisPtr, nint* result) Line 155 C#
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.Windows.UI.Xaml.dll!ABI.Windows.UI.Xaml.Controls.IFrameMethods.Navigate(WinRT.IObjectReference _obj, System.Type sourcePageType, object parameter) Line 70 C#
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Controls.Frame.Navigate(System.Type sourcePageType, object parameter) Line 389 C#
UWPAndDotNetNine.dll!UWPAndDotNetNine.App.OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs e) Line 52 C#
Microsoft.Windows.UI.Xaml.dll!Windows.UI.Xaml.Application.Windows.UI.Xaml.IApplicationOverrides.OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs args) Line 404 C#
Microsoft.Windows.UI.Xaml.dll!ABI.Windows.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_1(nint thisPtr, nint args) Line 51 C#
Expected Behavior
The application should run.
Version Info
TargetFramework = net9.0-windows10.0.26100.0
Microsoft.Windows.CsWinRT = 2.2.0
Additional Context
Sample application: CustomMediaPlayerElement.zip
Metadata
Metadata
Assignees
Labels
No labels