title: Why Is Xamarin.iOS crashing when I'm trying to acquire video
body: <p>HI All I am trying to convert some objective C Code to C# but the App crashes when ever It hits <em>AVCaptureDeviceInput.FromDevice</em></p>
  <pre><code>            if (_defaultDevice != null)
              {
                  NSError error;
                 var _defaultDeviceInput = AVCaptureDeviceInput.FromDevice(_defaultDevice, out error);
  </code></pre>
  <p>the Output is not helping ..</p>
  <pre><code>=================================================================
      Native Crash Reporting
  =================================================================
  Got a abrt while executing native code. This usually indicates
  a fatal error in the mono runtime or one of the native libraries 
  used by your application.
  =================================================================
  
  =================================================================
      Native stacktrace:
  =================================================================
      0x10116c6f8 - /private/var/containers/Bundle/Application/C68E54FC-7A9C-4AC3-BA8C-32E04DAD78BF/Flower.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
      0x1011628f0 - /private/var/containers/Bundle/Application/C68E54FC-7A9C-4AC3-BA8C-32E04DAD78BF/Flower.app/libmonosgen-2.0.dylib : mono_handle_native_crash
      0x10116bc40 - /private/var/containers/Bundle/Application/C68E54FC-7A9C-4AC3-BA8C-32E04DAD78BF/Flower.app/libmonosgen-2.0.dylib : sigabrt_signal_handler
      0x1e0edfd50 - /usr/lib/system/libsystem_platform.dylib : &lt;redacted&gt;
      0x1c0ddc594 - /usr/lib/system/libsystem_kernel.dylib : &lt;redacted&gt;
      0x1c0ddc5c4 - /usr/lib/system/libsystem_kernel.dylib : &lt;redacted&gt;
      0x1d8629800 - /System/Library/PrivateFrameworks/TCC.framework/TCC : &lt;redacted&gt;
      0x1d8624718 - /System/Library/PrivateFrameworks/TCC.framework/TCC : &lt;redacted&gt;
      0x1d8627394 - /System/Library/PrivateFrameworks/TCC.framework/TCC : &lt;redacted&gt;
      0x1e0f20cc8 - /usr/lib/system/libxpc.dylib : &lt;redacted&gt;
      0x1e0f15004 - /usr/lib/system/libxpc.dylib : &lt;redacted&gt;
      0x188113368 - /usr/lib/system/libdispatch.dylib : &lt;redacted&gt;
      0x1880cc38c - /usr/lib/system/libdispatch.dylib : &lt;redacted&gt;
      0x1880c3494 - /usr/lib/system/libdispatch.dylib : &lt;redacted&gt;
      0x1e0eeaf70 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
      0x1e0eeaaa4 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread
  
  =================================================================
      Basic Fault Address Reporting
  =================================================================
  Memory around native instruction pointer (0x1c0dda048):0x1c0dda038  c0 03 5f d6 c0 03 5f d6 30 41 80 d2 01 10 00 d4  .._..._.0A......
  0x1c0dda048  e3 00 00 54 fd 7b bf a9 fd 03 00 91 9f 65 ff 97  ...T.{.......e..
  0x1c0dda058  bf 03 00 91 fd 7b c1 a8 c0 03 5f d6 c0 03 5f d6  .....{...._..._.
  0x1c0dda068  90 32 80 d2 01 10 00 d4 e3 00 00 54 fd 7b bf a9  .2.........T.{..
  
  </code></pre>
  <p>has anyone got any idears what is happening ?</p>
  <p>Regards Christian Stœr</p>
  <p>here is more code</p>
  <pre><code>public BFCodeReader()
          {
              _metadataObjectTypes = AVMetadataObjectType.QRCode;
              SetUp();
          }
  
          private AVCaptureVideoPreviewLayer _previewLayer;
  
          private AVCaptureSession _session;
  
          private AVCaptureMetadataOutput _metadataOutput;
  
          private AVCaptureDevice _defaultDevice;
  
          private AVMetadataObjectType _metadataObjectTypes;
  
          private AVCaptureDeviceInput _defaultDeviceInput;
  
          private AVCaptureDevice _frontDevice;
  
          private AVCaptureDeviceInput _frontDeviceInput;
  
  
          // this maybe wrong but I need to return a handle
          public IntPtr Handle =&gt; this.Handle; //_session.Handle; 
  
          public IBFCodeSCanner ScannerDelegate;
  
          private void SetUp()
          {
  
              
              _defaultDevice = AVCaptureDevice.GetDefaultDevice(AVMediaType.Video);
              if (_defaultDevice != null)
              {
                  NSError error;
                  try
                  {
                      _defaultDeviceInput = AVCaptureDeviceInput.FromDevice(_defaultDevice, out error);
                  }
                  catch(Exception e)
                  {
                      Console.WriteLine(e.Message);
                  }
                  _metadataOutput = new AVCaptureMetadataOutput();
  
                  _session = new AVCaptureSession();
  
                  _previewLayer = new AVCaptureVideoPreviewLayer(_session);
  
                  AVCaptureDevice[] devices = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
                  foreach (var device in devices)
                  {
                      if (device.Position == AVCaptureDevicePosition.Front)
                      {
                          _frontDevice = device;
                          break;
                      }
                  }
  
                  if(_frontDevice != null)
                  {
                      _frontDeviceInput = new AVCaptureDeviceInput(_frontDevice, out _);
                  }
                  ConfigureComponents();
              }
              
          }
  </code></pre>
  <p>that is all the code</p>
  <p>PS class is BFCodeReader
  and the ConfigureComponente is empty at the moment</p>