title: Xamarin.iOS randomly crashes invalid cast exception
body: <p>I'm having some strange crashes in my app, I have tried to track the issue but happens randomly and in different clases or methods, all crashes are invalid cast exception but there is no logic in that... this is one of them</p>
  
  <pre><code>//ContactsViewController.cs
  //Initialize Components
  
  tableContact=IOTM.GUI.CreateTable(rTable,UIColor.White,UIColor.White,50f);
  refresh = IOTM.GUI.createRefreshControl (tableContact);
  refresh.ValueChanged += reloadData;
  //IOTM.GUI
  public static UIRefreshControl createRefreshControl(UITableView table){
          UIRefreshControl refresh=new UIRefreshControl ();
          var firstAttrib = new UIStringAttributes {
              ForegroundColor = UIColor.Black,
              BackgroundColor = UIColor.Clear,
              Font = UIFont.FromName("Helvetica", 10f )
          };
  
          string registerString = "Pull to Update Contacts";
          var styledRegisterString = new NSMutableAttributedString (registerString);
  
          styledRegisterString.AddAttributes(firstAttrib, new NSRange (0,registerString.Length) );
          refresh.AttributedTitle = styledRegisterString;
          refresh.TintColor = ICGlobal.OrangeLigth;
  
          table.AddSubview (refresh);
  
          return refresh;
      }
  public static UITableView CreateTable( RectangleF bounds, UIColor bgColor, UIColor lineColor, float rowHeight, UIView v = null)
      {
          UITableView t = new UITableView (bounds) {
              BackgroundColor = bgColor,
              SeparatorColor = lineColor,
              RowHeight = rowHeight
          };
  
          if (null != v) {
              v.AddSubview (t);
          }
          return t;
      }
  </code></pre>
  
  <p>And this is the error log</p>
  
  <pre><code>Unhandled Exception:
  0   CardReader_iOS                      0x004188a3 mono_handle_exception_internal + 2022
  1   CardReader_iOS                      0x004180b7 mono_handle_exception + 10
  2   CardReader_iOS                      0x004128dd mono_arm_throw_exception + 104
  3   CardReader_iOS                      0x002e6b9c throw_exception + 68
  at MonoTouch.Foundation.NSArray.UnsafeGetItem&lt;T&gt; (intptr,uint) &lt;0x00044&gt;
  at MonoTouch.Foundation.NSArray.ArrayFromHandle&lt;T&gt; (intptr) &lt;0x0008c&gt;
  at MonoTouch.UIKit.UIView.get_Subviews () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIView.g.cs:2402
  at MonoTouch.UIKit.UIView.AddSubview (MonoTouch.UIKit.UIView) [0x0005c] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIView.g.cs:475
  at Core_IC_IOTM.GUI.createRefreshControl (MonoTouch.UIKit.UITableView) &lt;IL 0x00075, 0x00368&gt;
  at CardReader_iOS.ContactsViewController.InitializeComponents () &lt;IL 0x00368, 0x01924&gt;
  at CardReader_iOS.ICBaseController.ViewDidLoad () &lt;IL 0x00018, 0x000d4&gt;
  at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) &lt;0x000c8&gt;
  12  CardReader_iOS                      0x004243f5 mono_jit_runtime_invoke + 1196
  13  CardReader_iOS                      0x0046059d mono_runtime_invoke + 88
  14  CardReader_iOS                      0x003f4e69 native_to_managed_trampoline_CardReader_iOS_ICBaseController_ViewDidLoad + 232
  15  UIKit                               0x30e224cb &lt;redacted&gt; + 518
  16  UIKit                               0x30e22289 &lt;redacted&gt; + 24
  17  UIKit                               0x30fae38b &lt;redacted&gt; + 634
  18  UIKit                               0x30ecbd83 &lt;redacted&gt; + 418
  19  UIKit                               0x30ecbb8d &lt;redacted&gt; + 44
  20  UIKit                               0x30ecbb25 &lt;redacted&gt; + 184
  21  UIKit                               0x30e1dd79 &lt;redacted&gt; + 380
  22  QuartzCore                          0x30a9b62b &lt;redacted&gt; + 142
  23  QuartzCore                          0x30a96e3b &lt;redacted&gt; + 350
  24  QuartzCore                          0x30a96ccd &lt;redacted&gt; + 16
  25  QuartzCore                          0x30a966df &lt;redacted&gt; + 230
  26  QuartzCore                          0x30a964ef &lt;redacted&gt; + 314
  27  UIKit                               0x30e21401 &lt;redacted&gt; + 8232
  28  CoreFoundation                      0x2e5cd25b &lt;redacted&gt; + 14
  29  CoreFoundation                      0x2e5cc72b &lt;redacted&gt; + 206
  30  CoreFoundation                      0x2e5caf1f &lt;redacted&gt; + 622
  31  CoreFoundation                      0x2e535f4f CFRunLoopRunSpecific + 522
  32  CoreFoundation                      0x2e535d33 CFRunLoopRunInMode + 106
  33  GraphicsServices                    0x3343a663 GSEventRunModal + 138
  34  UIKit                               0x30e8116d UIApplicationMain + 1136
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) &lt;0x00110&gt;
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38
  at CardReader_iOS.Application.Main (string[]) &lt;IL 0x0000c, 0x0007c&gt;
  at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) &lt;0x000c8&gt;
  39  CardReader_iOS                      0x004243f5 mono_jit_runtime_invoke + 1196
  40  CardReader_iOS                      0x0046059d mono_runtime_invoke + 88
  41  CardReader_iOS                      0x00464177 mono_runtime_exec_main + 282
  42  CardReader_iOS                      0x00463fb7 mono_runtime_run_main + 474
  43  CardReader_iOS                      0x004126e5 mono_jit_exec + 48
  44  CardReader_iOS                      0x004b0fe8 main + 2464
  45  libdyld.dylib                       0x392bbab7 &lt;redacted&gt; + 2
  
  Mar 17 17:33:19 iPhone-de-Hector CardReader_iOS[4306] &lt;Warning&gt;: Unhandled managed exception: Unable to cast object of type 'MonoTouch.UIKit.UIScrollView+_UIScrollViewDelegate' to type 'MonoTouch.UIKit.UIView'. (System.InvalidCastException)
    at MonoTouch.ObjCRuntime.Runtime.GetINativeObject[UIView] (IntPtr ptr, Boolean owns) [0x00000] in &lt;filename unknown&gt;:0 
    at MonoTouch.Foundation.NSArray.UnsafeGetItem[UIView] (IntPtr handle, UInt32 index) [0x00000] in &lt;filename unknown&gt;:0 
    at MonoTouch.Foundation.NSArray.ArrayFromHandle[UIView] (IntPtr handle) [0x00000] in &lt;filename unknown&gt;:0 
    at MonoTouch.UIKit.UIView.get_Subviews () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIView.g.cs:2402 
    at MonoTouch.UIKit.UIView.AddSubview (MonoTouch.UIKit.UIView view) [0x0005c] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIView.g.cs:475 
    at Core_IC_IOTM.GUI.createRefreshControl (MonoTouch.UIKit.UITableView table) [0x00000] in &lt;filename unknown&gt;:0 
    at CardReader_iOS.ContactsViewController.InitializeComponents () [0x00000] in &lt;filename unknown&gt;:0 
    at CardReader_iOS.ICBaseController.ViewDidLoad () [0x00000] in &lt;filename unknown&gt;:0 
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 
    at CardReader_iOS.Application.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0 
  </code></pre>