title: System.Reflection.TargetInvocationException thrown when trying to instantiate new ViewController
body: <p>I have a storyboard. Because I load a view in code (depending on conditions) I haven't used the segue anymore. Now I want to load another view but I'm getting the following error:</p>
  
  <blockquote>
    <p>System.Reflection.TargetInvocationException was thrown<br>
    Exception has been thrown by the target of an invocation.</p>
  </blockquote>
  
  <pre><code>ListButton.TouchUpInside += (object sender, EventArgs e) =&gt; {
      MyListController myListController = this.Storyboard.InstantiateViewController ("MyListController") as MyListController;
      myListController.EdgesForExtendedLayout = UIRectEdge.None;
      if (myListController != null) {
          this.NavigationController.PushViewController (myListController, true);
      }
  };
  </code></pre>
  
  <p>When the button (ListButton) is pressed the view should be loaded onto the navigation stack. The error occurs with <code>InstantiateViewController</code>.</p>
  
  <p>How can I solve that?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I went into MyListController and if I comment the following out the view gets loaded:</p>
  
  <pre><code>public MyListController (IntPtr handle) : base (handle)
  {
      TableView.RegisterClassForCellReuse (typeof(UITableViewCell), listCellId);
      TableView.Source = new MyListDataSource (this);
      MyList = new List&lt;string&gt; ();
  }
  </code></pre>
  
  <p>Log:</p>
  
  <blockquote>
    <p>System.Reflection.TargetInvocationException: Exception has been thrown
    by the target of an invocation. ---> System.Exception: Object
    reference not set to an instance of an object   at
    TestApp.MyListController.ViewDidLoad () [0x0004c] in
    /Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:78<br>
    at at (wrapper managed-to-native)
    MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper
    (intptr,intptr)   at
    MonoTouch.UIKit.UITableViewController.get_TableView () [0x00000] in
    :0   at TestApp.MyListController..ctor (IntPtr
    handle) [0x00009] in
    /Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:17<br>
    at at (wrapper managed-to-native)
    System.Reflection.MonoCMethod:InternalInvoke
    (System.Reflection.MonoCMethod,object,object[],System.Exception&amp;)   at
    System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
    System.Object[] parameters) [0x00002] in
    /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537
    --- End of inner exception stack trace ---   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
    System.Object[] parameters) [0x00016] in
    /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
    at System.Reflection.MonoCMethod.DoInvoke (System.Object obj,
    BindingFlags invokeAttr, System.Reflection.Binder binder,
    System.Object[] parameters, System.Globalization.CultureInfo culture)
    [0x00095] in
    /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:528
    at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr,
    System.Reflection.Binder binder, System.Object[] parameters,
    System.Globalization.CultureInfo culture) [0x00000] in
    /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:556
    at System.Reflection.ConstructorInfo.Invoke (System.Object[]
    parameters) [0x00000] in
    /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
    at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject[NSObject] (IntPtr
    ptr, System.Type type, MissingCtorResolution missingCtorResolution)
    [0x00000] in :0   at
    MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr
    klass, MissingCtorResolution missingCtorResolution) [0x00000] in
    :0   at MonoTouch.ObjCRuntime.Runtime.GetNSObject
    (IntPtr ptr, MissingCtorResolution missingCtorResolution) [0x00000] in
    :0   at MonoTouch.ObjCRuntime.Runtime.GetNSObject
    (IntPtr ptr) [0x00000] in :0   at
    MonoTouch.UIKit.UIStoryboard.InstantiateViewController (System.String
    identifier) [0x00000] in :0   at
    TestApp.StartScreenViewController.m__1 (System.Object
    sender, System.EventArgs e) [0x0000c] in
    /Users/xxx/Projects/TestApp/TestApp/TestApp/StartScreenViewController.cs:57
    at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
    :0   at 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) [0x00000] in :0   at
    TestApp.Application.Main (System.String[] args) [0x00008] in
    /Users/xxx/Projects/TestApp/TestApp/TestApp/Main.cs:17</p>
  </blockquote>
  
  <p><strong>Try:</strong><br>
  Hmm, now I added a new UITableViewController to the storyboard, changed some classes to public, changed variable names to starting with lower case. Also the old UITableviewController had a problem with an added SearchController. Now I made everything new and the problem only relied in the <code>viewDidLoad</code> but that was not the original problem. It was one of these steps (perhaps the SearchController problem).</p>
  
  <p><strong>Problematic Code:</strong></p>
  
  <pre><code>this.NavigationController.ToolbarHidden = false;
  </code></pre>
  
  <p>It seems that he can't find the <code>NavigationController</code> ... How do I addd the navigation controller to the new created view?</p>