C# 在WPF中创建Windows.UI.Composition.Compositor实例抛出0x80070005访问被拒绝
我正在尝试从WPF项目中使用Windows.UI.Composition API。 这似乎是可行的 但是,在新项目中使用它会引发异常:C# 在WPF中创建Windows.UI.Composition.Compositor实例抛出0x80070005访问被拒绝,c#,.net,wpf,C#,.net,Wpf,我正在尝试从WPF项目中使用Windows.UI.Composition API。 这似乎是可行的 但是,在新项目中使用它会引发异常: System.UnauthorizedAccessException HResult=0x80070005 Message=Access is denied. Access is denied. Source=Windows.UI StackTrace: at Windows.UI.Composition.Compositor..ct
System.UnauthorizedAccessException
HResult=0x80070005
Message=Access is denied.
Access is denied.
Source=Windows.UI
StackTrace:
at Windows.UI.Composition.Compositor..ctor()
at CaptureMonkey.MainWindow.MainWindow_Loaded(Object sender, RoutedEventArgs e) in C:\Users\max\source\repos\CaptureMonkey\CaptureMonkey\MainWindow.xaml.cs:line 79
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
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.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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)
这是由以下因素触发的:
compositor = new Compositor();
排字员:
private Windows.UI.Composition.Compositor compositor;
这可能是什么原因造成的
在UWP应用程序中,我可以通过分配正确的权限来使用此API,但在示例项目中似乎没有此设置。应用程序引导未完成。调度器需要按照以下要求设置: