I'm testing out MvvmCross in an existing Monotouch project. I would like to start migrating the project to Mvvm in pieces.
I can start the application and it shows my first (mvvm) screen. After that, i'm doing different (non mvvmcross) things (loading views etc) which I would like to port on a later moment.
I was now trying to port one of my views also to mvvmcross. I created a View "public class TestView : MvxViewController" and a ViewModel "public class TestViewModel : MvxViewModel"
When loading that View, the app crashed with following error:
---Message:
Object reference not set to an instance of an object
---Stack Trace:
at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods+<OnViewCreate>c__AnonStorey3.<>m__9 () [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) <Module>:invoke_void__this___object_EventArgs (object,System.EventArgs)
at Cirrious.CrossCore.Touch.Views.MvxDelegateExtensionMethods.Raise (System.EventHandler eventHandler, System.Object sender) [0x00000] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Views.MvxEventSourceViewController.ViewDidLoad () [0x00000] in <filename unknown>:0
at CatalogMVVMTest.Touch.Views.TestView.ViewDidLoad () [0x0001a] in /Users/matthiasvalcke/Projects/MVVMDemos/CatalogMVVMTest/CatalogMVVMTest.Touch/Views/TestView.cs:20
...
It seems it crashes when calling "base.ViewDidLoad ();"
Not sure if this is important, but after loading the first view, I'm loading a new (non mvvmcross) view as root of the navigation stack.
So now I'm trying to load a MvvmCross View to a normal UIView(Controller)
I'm also getting following Mvx diagnostic output:
mvx: Diagnostic: 1.08 Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction
edit:
I'm also getting it if I just edit a simple sample from MvvmCross. For example, if I just take the basic sample with one "FirstView" and "FirstViewModel" and I do something like this, I'm getting the error:
var secondv = new SecondView ();
secondv.View.Frame = new RectangleF (0,250,320,100);
Add (secondv.View);
SecondView is just a MvxViewController. It seems like I can not add a View from a MvxViewController to another MvxViewController in code. Is this correct?
Anyone having an idea?