Invalid cast exception when using ShowViewModel<>(); using UITabBarController - xamarin.ios

After update from mvvmcross 4.4.0 to 5.0.5 method ShowViewModel<SettingsViewModel>(); throws System.InvalidCastException. Output is:
mvx:Diagnostic:121.13 Showing ViewModel SettingsViewModel
iOSNavigation:Diagnostic:121.13 Navigate requested
mvx:Diagnostic:121.16 PresentationAttribute not found for SettingsViewController. Assuming animated Child presentation
and a StackTrace :
at MvvmCross.iOS.Views.MvxTabBarViewController.ShowChildView (UIKit.UIViewController viewController) [0x00007] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.ShowChildViewController (UIKit.UIViewController viewController, MvvmCross.iOS.Views.Presenters.Attributes.MvxChildPresentationAttribute attribute, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x0004a] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.<RegisterAttributeTypes>b__20_1 (UIKit.UIViewController vc, MvvmCross.iOS.Views.Presenters.Attributes.MvxBasePresentationAttribute attribute, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00000] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.Show (MvvmCross.iOS.Views.IMvxIosView view, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x0002c] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.Show (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00009] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosViewDispatcher+<>c__DisplayClass2_0.<ShowViewModel>b__0 () [0x00016] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosUIThreadDispatcher.RequestMainThreadAction (System.Action action) [0x0001f] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosViewDispatcher.ShowViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00022] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModelImpl (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x0002c] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x00000] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel[TViewModel] (MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x00000] in <ed129c02df414c1d8cea008ca80d94cb>:0
at FreQuest.ViewModels.Tabs.MyProfileViewModel.<get_SettingsCommand>b__35_0 () [0x00001] in /Users/pavlomelnyk/frequest-ios-xamarin/FreQuest/ViewModels/Tabs/MyProfileViewModel.cs:114
at MvvmCross.Core.ViewModels.MvxCommand.Execute (System.Object parameter) [0x00009] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Binding.iOS.Target.MvxUIControlTargetBinding.ControlEvent (System.Object sender, System.EventArgs eventArgs) [0x00025] in <78be62c59fd541e38ea9b95c6cd03bdc>:0
at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIControl.cs:38
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at FreQuest.iOS.Application.Main (System.String[] args) [0x00001] in /Users/pavlomelnyk/frequest-ios-xamarin/iOS/Main.cs:17
I invoke ShowViewModel<SettingsViewModel>(); in MyProfileViewModel that is in UITabBarController that extends MvxTabBarViewController. My guess is somehow ViewModels related to TabBarContreller do not "see" SettingsViewController.
Has somebody face same issue? Your feedback will be very helpful.
Thanks

Related

System.ArgumentNullException: missing source event info in MvxWeakEventSubscription

We are using data binding in our Xamarin.IOS project using MvvmCross(Hot Tuna version) as specified in the sample app “N-39-CrossLight-Touch”.
The sample app as well as our project works fine on simulator(IOS7) but on device(IOS7) it throws the below exception while binding.
System.ArgumentNullException: missing source event info in
MvxWeakEventSubscription Parameter name: sourceEventInfo at
Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription2[System.ComponentModel.INotifyPropertyChanged,System.ComponentModel.PropertyChangedEventArgs]..ctor
(INotifyPropertyChanged source, System.Reflection.EventInfo
sourceEventInfo, System.EventHandler1 targetEventHandler) [0x00000] in
:0 at
Cirrious.CrossCore.WeakSubscription.MvxNotifyPropertyChangedEventSubscription..ctor
(INotifyPropertyChanged source, System.EventHandler1
targetEventHandler) [0x00000] in :0 at
Cirrious.CrossCore.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe
(INotifyPropertyChanged source, System.EventHandler1 eventHandler)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxLeafPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxSimpleLeafPropertyInfoSourceBinding..ctor
(System.Object source, System.Reflection.PropertyInfo propertyInfo)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxPropertySourceBindingFactoryExtension.CreateLeafBinding
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
propertyToken) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxPropertySourceBindingFactoryExtension.TryCreateBinding
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
currentToken, System.Collections.Generic.List1 remainingTokens,
IMvxSourceBinding& result) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.TryCreateBindingFromExtensions
(System.Object source,
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyToken
propertyToken, System.Collections.Generic.List1 remainingTokens,
IMvxSourceBinding& result) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding
(System.Object source, IList1 tokens) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding
(System.Object source, System.String combinedPropertyName) [0x00000]
in :0 at
Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxPathSourceStep.OnDataContextChanged
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxSourceStep.set_DataContext
(System.Object value) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.CreateSourceBinding
(System.Object source) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding..ctor
(Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle
(Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRequest)
[0x00000] in :0 at
Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder+<>c_DisplayClass1.b_0
(Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription
description) [0x00000] in :0 at
System.Linq.Enumerable+c__Iterator102[Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription,Cirrious.MvvmCross.Binding.Bindings.IMvxUpdateableBinding].MoveNext
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings
(IMvxBindingContextOwner view, IEnumerable1 bindings, System.Object
clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings
(IMvxBindingContextOwner view, System.Object target, IEnumerable1
bindingDescriptions, System.Object clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding
(IMvxBindingContextOwner view, System.Object target,
Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription
bindingDescription, System.Object clearKey) [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription1[MonoTouch.UIKit.UITextField].Apply
() [0x00000] in :0 at
Cirrious.MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet2[CrossLightTouch.MyViewController,CrossLightTouch.ViewModels.MyViewModel].Apply
() [0x00000] in :0 at CrossLightTouch.MyViewController.ViewDidLoad ()
[0x0024f] in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/MyViewController.cs:81
at at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr) at
MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00008] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIWindow.g.cs:129
at CrossLightTouch.AppDelegate.FinishedLaunching
(MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary
options) [0x00042] in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/AppDelegate.cs:25
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) [0x0004c] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIApplication.cs:38
at CrossLightTouch.Application.Main (System.String[] args) [0x00008]
in
/Users/admin/Downloads/N-39-CrossLight-Touch/CrossLightTouch/Main.cs:17
By setting the IOS build options -> Link Behavior -> Don’t link , it works on device as expected, but the binary size has been doubled.
You can reproduce this issue with “N-39-CrossLight-Touch” sample.
Is there a fix or alternative for this?
If you don't already have a LinkerPleaseInclude file, copy the one from here into your project:
https://github.com/MvvmCross/MvvmCross/blob/6ab1baa9ca128921208efa994890039edf398474/TestProjects/Android-Support/Fragments/Example.Droid/LinkerPleaseInclude.cs
Also, add the following line to the Include(TextView text) method:
text.AfterTextChanged += (sender, args) => text.Text = "" + text.Text;
If that doesn't solve it, look for other events that may be used in the Mvx bindings and add those to the LinkerPleaseInclude file.
This issue is caused by the dynamic nature of Mvx binding on Android. Because the bindings are resolved at runtime, the Xamarin linker thinks the UI events they reference are not being used so they are removed from the final build. Adding references in the LinkerPleaseInclude file forces them to be included.

Teechart application crashing in iphone

when using steema Teechart, its working fine in simulator, but application crashing when using in iphone,
its shows following error
System.NullReferenceException: Object reference not set to an instance of an object
at Steema.TeeChart.TChart.ApplyScroll () [0x00000] in :0
at Steema.TeeChart.TChart.m__0 (System.Object sender, System.EventArgs e) [0x00000] in :0
at MonoTouch.UIKit.UIScrollView+_UIScrollViewDelegate.Scrolled (MonoTouch.UIKit.UIScrollView scrollView) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIScrollView.g.cs:991
at MonoTouch.UIKit.UIScrollView.SetContentOffset (PointF contentOffset, Boolean animated) [0x00010] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIScrollView.g.cs:208
at Steema.TeeChart.TChart.Draw (RectangleF rect) [0x00000] in :0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at CropManageriPhone.Application.Main (System.String[] args) [0x00000] in /Users/vss1/VSS Projects/CP Live/CropManageriPhone04022013/CropManageriPhone/Main.cs:17
and We are using monotouch version 6.0.4
i found solution for this,
i set ZoomScrollStyle for the chart control,
_controller.chart.Aspect.ZoomScrollStyle=Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;

When I run app with or without Degugging it give me an error System.ExecutionEngineException: SIGILL

When I run app with or without Degugging it give me an error as below
**Unhandled Exception: System.ExecutionEngineException: SIGILL
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) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at DicomViewerApplication.Application.Main (System.String[] args) [0x00000] in /Developer/Medsynaptic/DicomViewerApplication/DicomViewerApplication/Main.cs:18
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: SIGILL
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) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at DicomViewerApplication.Application.Main (System.String[] args) [0x00000] in /Developer/Medsynaptic/DicomViewerApplication/DicomViewerApplication/Main.cs:18 **
but when I run the app from simulator it works properly I want to check the values that come with debugger but it give me an error
This question is likely solved in the latest version of Xamarin

How to add CoreData Model File .momd into MonoTouch project

The MonoTouch solution includes two projects.
MonoTouch Binding Project: API Contract interfaces for linked native
ObjC library
Test Client Application
The native ObjC library requires to include Core Data Model file (.momd). I have added it to the project of Test App.
But app crashes with the following error:
Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261
at CombinedControllerApp.MainController.<ViewDidLoad>m__2 (System.Object , System.EventArgs ) [0x0003d] in /Users/mahmood1/Documents/Projects/TouchNote-Prototype/CombinedControllerApp/MainController.cs:96
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30
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) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at CombinedControllerApp.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Documents/Projects/TouchNote-Prototype/CombinedControllerApp/Main.cs:17
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261
at CombinedControllerApp.MainController.<ViewDidLoad>m__2 (System.Object , System.EventArgs ) [0x0003d] in /Users/mahmood1/Documents/Projects/TouchNote-Prototype/CombinedControllerApp/MainController.cs:96
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30
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) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at CombinedControllerApp.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Documents/Projects/TouchNote-Prototype/CombinedControllerApp/Main.cs:17
How to add this needed CoreData Model File into Test Application that it will be visible for the native library?
Thanks!
(Sources are here : http://www.axifile.com/en/71EC96914A)
Per my comment:
Adding most files like this to your project with Build Action of Content will solve the issue.

Monotouch - NSInvalidArgumentException

I've got this error:
2011-03-28 15:38:07.154 FolderNavigation[264:207] -[Subfolder _setViewDelegate:]: unrecognized selector sent to instance 0x6eaafd0
Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[Subfolder _setViewDelegate:]: unrecognized selector sent to instance 0x6eaafd0
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) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31
at FolderNavigation.Application.Main (System.String[] args) [0x00000] in /Users/claudio/Projects/FolderNavigation/FolderNavigation/Main.cs:16
Error connecting stdout and stderr (127.0.0.1:10001)
and following de code using Debug(using Step Into)
Starting on Main.cs:
static void Main (string[] args)
{
UIApplication.Main (args);
}
Subfolder.xib.cs(next Step Into)
[Export("initWithCoder:")]
public Subfolder (NSCoder coder) : base(coder)
{
Initialize ();
}
void Initialize ()
{
}
and in the next step, I have got this error.
Does anybody have an idea?
Thanks in advance!
Is this a View or ViewController? My auto-generated files have a public Subfolder() : base("Subfolder", null) constructor, which I don't see here.
Also, which version of XCode & MT are you running?

Resources