Metro style media application exclusion exception

I am writing my first metro style app. A few days ago I wrote a code for taking photos based on this sample ( here ), and it works. With the release of the official release of the version of Windows 8 and the visual studio version of 2012, the same fragment does not work. There seems to be a problem with accessing the camera, but in Package.appxmanifest I checked the capabilities of the webcam. xaml:

<Canvas x:Name="previewCanvas1" Width="320"  Height="240" Background='Gray'>
<Image x:Name="imageElement1"  Width="320" Height="240" Visibility="Collapsed"/>
<CaptureElement x:Name="previewElement1" Width="320" Height="240" />
</Canvas>
<StackPanel Orientation="Horizontal" Margin="20" HorizontalAlignment="Center">
 <Button Width="120" x:Name="btnStartPreview2" Click="btnStartPreview_Click" IsEnabled="true"  Margin="0,0,10,0"  Background="#FFC3C3C3">Da Webcam</Button>
<Button Width="120" x:Name="btnTakePhoto2" Click="btnTakePhoto_Click" IsEnabled="false"  Margin="0,0,10,0"  Background="#FFC3C3C3">Scatta</Button>
</StackPanel>

And the code behind:

MediaCapture mediaCaptureMgr;
async void btnStartPreview_Click(Object sender, RoutedEventArgs e)
        {
            try
            {

                mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
                await mediaCaptureMgr.InitializeAsync();

                previewElement1.Source = mediaCaptureMgr;

                await mediaCaptureMgr.StartPreviewAsync();

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

exception: " Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) ", but as said, the ability of the webcam is checked!

+5
source share
1 answer

. -, package.appxmanifest, - . , !

+9

All Articles