简体   繁体   中英

Windows Phone - Access to camera requires the ISV Camera Capability

I am building a Windows Phone app which uses the camera. I have the code:

 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {

 if ((PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) ||
     (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) == true))  {
     // Initialize the default camera.
     _photoCamera = new Microsoft.Devices.PhotoCamera();

     //Event is fired when the PhotoCamera object has been initialized
     _photoCamera.Initialized += new EventHandler<Microsoft.Devices.CameraOperationCompletedEventArgs>(OnPhotoCameraInitialized);

      //Set the VideoBrush source to the camera
      viewfinderBrush.SetSource(_photoCamera);
  }
  else {
      // The camera is not supported on the device.
      this.Dispatcher.BeginInvoke(delegate()  {
      // Write message.
          txtDebug.Text = "A Camera is not available on this device.";
      });

  }

}

private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e) {
    int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
    int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);
}

And I keep getting the exception: "Access to camera requires the ISV Camera Capability."

I have a Lumia 900 , and I know it runs camera APIs (the sample form MS works fine). But when I go to put this code in my app, I get this exception. Does anyone have any idea what might be going on? I am a good C# 'er, but the Windows Phone is quite new to me.

Many thanks! Brett

Solved it : I had to add the line:

<Capability Name="ID_CAP_ISV_CAMERA"/>

to my WMAppManifent.xml file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM