ProjectionManager.StartProjectingAsync-抛出“拒绝访问”异常

时间:2018-07-04 12:22:42

标签: c# casting uwp projection

ProjectionManager.StartProjectingAsync api引发异常。 我需要什么? 我有一个uwp应用程序。在按钮上单击,我需要选择一个miracast设备并连接到它,并为其(或页面)投影一个新视图。 操作系统:Windows 10,Versio 1709(操作系统内部版本16299.492)

projectorSelectorQuery = "(System.Devices.DevObjectType:= 5 AND System.Devices.Aep.ProtocolId:= \"{0407d24e-53de-4c9a-9ba1-9ced54641188}\" AND System.Devices.WiFiDirect.Services:~=\"Miracast\")";

因此只有miracast设备可见。

var outputDevices = await DeviceInformation.FindAllAsync(projectorSelectorQuery);

我选择了一个miracast设备并开始投影到它。

if (ProjectionViewPageControl == null)
        {
            // First, create a new, blank view
            var thisDispatcher = Window.Current.Dispatcher;
            await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // ViewLifetimeControl is a wrapper to make sure the view is closed only
                // when the app is done with it
                ProjectionViewPageControl = ViewLifetimeControl.CreateForCurrentView();

                // Assemble some data necessary for the new page
                var initData = new ProjectionViewPageInitializationData();
                initData.MainDispatcher = thisDispatcher;
                initData.ProjectionViewPageControl = ProjectionViewPageControl;
                initData.MainViewId = thisViewId;

                // Display the page in the view. Note that the view will not become visible
                // until "StartProjectingAsync" is called
                var rootFrame = new Frame();

                rootFrame.Navigate(typeof(BlankPage1), initData);
                Window.Current.Content = rootFrame;

                // The call to Window.Current.Activate is required starting in Windos 10.
                // Without it, the view will never appear.
                Window.Current.Activate();
            });
        }

        try
        {
            // Start/StopViewInUse are used to signal that the app is interacting with the
            // view, so it shouldn't be closed yet, even if the user loses access to it
            ProjectionViewPageControl.StartViewInUse();

            // Show the view on a second display that was selected by the user

            await ProjectionManager.StartProjectingAsync(ProjectionViewPageControl.Id, thisViewId, selectedDisplay);
            ProjectionViewPageControl.StopViewInUse();
        }
        //catch(InvalidOperationException)
        catch (Exception exception)
        {

            var msg = new MessageDialog(exception.Message + " Stack: " + exception.StackTrace + " Source: " + exception.Source);
           await msg.ShowAsync();
        }

实际上会发生什么,它将连接到Miracast设备-意味着我的屏幕已镜像到它。但是我的页面没有投影。

I am getting this exception

0 个答案:

没有答案