0

カメラを使用するWindowsPhoneアプリを作成しています。私はコードを持っています:

 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);
}

そして、 「カメラへのアクセスにはISVカメラ機能が必要です」という例外が発生し続け ます。

私はを持っていますLumia 900、そしてそれがカメラを動かしていることを知っていますAPIs(サンプルフォームMSはうまくいきます)。しかし、このコードをアプリに配置しようとすると、この例外が発生します。誰かが何が起こっているのか考えていますか?私は良いC#人ですが、WindowsPhoneは私にとってまったく新しいものです。

どうもありがとう!ブレット

4

1 に答える 1

4

解決しました:次の行を追加する必要がありました:

<Capability Name="ID_CAP_ISV_CAMERA"/>

私のWMAppManifent.xmlファイルに。

于 2012-05-14T18:42:30.513 に答える