title: Windows Phone 8.1 camera initialization
body: <p>I am aware about that there are more duplicate questions about this, but please, it is super important to me. I have hard time now with Windows Phone 8.1 C# camera initialization.</p>
  
  <pre><code>async private void InitCamera_Click(object sender, RoutedEventArgs e)
      {
          captureManager = new MediaCapture();
          await captureManager.InitializeAsync();
  
           try 
          {
              captureManager = new Windows.Media.Capture.MediaCapture();
              await captureManager.InitializeAsync();
  
              if (captureManager.MediaCaptureSettings.VideoDeviceId != "" &amp;&amp; captureManager.MediaCaptureSettings.AudioDeviceId != "") 
              {
                  System.Diagnostics.Debug.WriteLine("Init successful");
  
  
                  captureManager.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded);
                  captureManager.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(Failed); 
              } 
              else 
              {
                  System.Diagnostics.Debug.WriteLine("No Device");
              } 
          }
           catch (Exception exception)
           {
               System.Diagnostics.Debug.WriteLine("Exception raised!!!!:" + exception);
           } 
      }
  </code></pre>
  
  <p>this is my code to initialize camera, but for some reason it fails on <code>Windows.Media.Capture.MediaCapture()</code> constructor call with <code>System.UnauthorizedAccessException</code> on Lumia 920 and also Access Violation on emulator. I've googled about the issue, but no answers so far. Some folks told that I should enable not just webcam, but also microphone, but that did not solved my issue. Everything seems to be well set, all access were granted in app manifest. Also I want to ask you, if you have some good and working example/tutorial of taking pictures with camera, please provide.</p>