Mvvmcross: Working with Xamarin.ios using MvvmCross Framework, getting System.ArgumentNullException.

Created on 12 Jun 2018  路  19Comments  路  Source: MvvmCross/MvvmCross



Steps to reproduce :scroll:

  1. Created new solution with .net standard library project (version 2.0) with MvvmCross nuget package included, also created App.cs class here at root level.

  2. Added new project for Xamarin.iOS with core project referenced created in 1st step with MvvmCross nuget package, included LinkerPleaseInclude.cs file. Make all the required changes according to MvvmCrossDocumentation and with following Redme.txt file of new 6.1.0 version

  3. Now build and run the project i'm getting the Exception at set.Applay() line excecution

set apply

If, I comment this line and run the project it will run perfectly but data binding will not apply as it has to be according to the MvvmCross documentation.

Expected behavior :thinking:

The project have to run successfully without this exception and with proper data binding too.

Actual behavior :bug:

It is throws System.ArgumentNullException and if not using the set.Apply() then data binding not works.
I have attached the screen shot of the Exception I'm get, please check it.

Configuration :wrench:

Version: 6.0.1 or 6.1.0

Platform:

  • [ ] :iphone: iOS
ios needs-more-info

Most helpful comment

Bingo

All 19 comments

I have also try to run the sample (Mvx-00-FirstDemo) which I have found from below link: https://github.com/nickrandolph/MvxPlus1DaysOfMvvmCross

In this also I have get the same System.ArgumentNullException with same behaviour I have mentioned above.

Please provide the full stack trace.

firstdemo_stack_trace

That is not it.

I am asking for the stack trace. With line numbers. Also not a screenshot. Easiest way to get this is just let the app continue and look in the Application Output pad

Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/Xamarin.iOS.dll [External]
Thread started:  #2
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/FirstDemo.iOS.exe
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/MvvmCross.dll [External]
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/FirstDemo.Core.dll
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/System.dll [External]
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/System.Core.dll [External]
Loaded assembly: /Users/ns-mac/Library/Developer/CoreSimulator/Devices/DD955F6F-E1B4-4DEF-8CCD-E826AD7CD2CE/data/Containers/Bundle/Application/F49B28DF-F506-4A78-AEE1-072AF36C29EE/FirstDemo.iOS.app/Microsoft.CSharp.dll [External]
2018-06-12 15:44:25.426 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Primary start
2018-06-12 15:44:25.426 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: FirstChance start
2018-06-12 15:44:25.426 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: PlatformServices start
2018-06-12 15:44:25.431 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: MvvmCross settings start
2018-06-12 15:44:25.431 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Singleton Cache start
2018-06-12 15:44:25.432 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: ViewDispatcher start
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
2018-06-12 15:44:25.448 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Bootstrap actions
2018-06-12 15:44:25.455 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: StringToTypeParser start
2018-06-12 15:44:25.457 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: CommandHelper start
2018-06-12 15:44:25.458 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: PluginManagerFramework start
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
Thread started: <Thread Pool> #9
2018-06-12 15:44:25.497 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Create App
2018-06-12 15:44:25.500 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: NavigationService
2018-06-12 15:44:25.505 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Load navigation routes
2018-06-12 15:44:25.508 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: App start
2018-06-12 15:44:25.508 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Application Initialize - On background thread
2018-06-12 15:44:25.510 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: ViewModelTypeFinder start
2018-06-12 15:44:25.514 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: ViewsContainer start
2018-06-12 15:44:25.515 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Views start
2018-06-12 15:44:25.526 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: CommandCollectionBuilder start
2018-06-12 15:44:25.527 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: NavigationSerializer start
2018-06-12 15:44:25.527 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: InpcInterception start
2018-06-12 15:44:25.528 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: InpcInterception start
2018-06-12 15:44:25.528 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: LastChance start
2018-06-12 15:44:25.575 FirstDemo.iOS[4061:235209] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Secondary end
2018-06-12 15:44:25.577 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Logging.MvxLog) AppStart: Application Startup - On UI thread
2018-06-12 15:44:25.600 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Logging.MvxLog) iOSNavigation
2018-06-12 15:44:25.610 FirstDemo.iOS[4061:235026] 2018-06-12 03:44:25 [TRACE] (MvvmCross.Logging.MvxLog) PresentationAttribute nor MasterNavigationController found for FirstView. Assuming Root presentation

That is still not the stack trace 馃槃 Could you please use your favorite search engine to figure out what a stack trace is?

System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
  at MvvmCross.WeakSubscription.MvxWeakEventSubscription`1[TSource]..ctor (UIKit.UITextField source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler targetEventHandler) [0x0001d] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.WeakSubscription.MvxWeakEventSubscription`1[TSource]..ctor (UIKit.UITextField source, System.String sourceEventName, System.EventHandler targetEventHandler) [0x00012] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.WeakSubscription.MvxWeakSubscriptionExtensions.WeakSubscribe[TSource] (TSource source, System.String eventName, System.EventHandler eventHandler) [0x00000] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Platforms.Ios.Binding.Target.MvxUITextFieldTextTargetBinding.SubscribeToEvents () [0x00037] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00056] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () [0x0003a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/external/corefx/src/System.Linq/src/System/Linq/Select.cs:224 
  at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindings, System.Object clearKey) [0x0001d] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindingDescriptions, System.Object clearKey) [0x00018] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x0000b] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[TTarget].Apply () [0x0001f] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[TOwningTarget,TSource].Apply () [0x00016] in <8a077b300d9c484ab0471c2d21c3cb26>:0 
  at FirstDemo.iOS.Views.FirstView.ViewDidLoad () [0x00102] in /Users/ns-mac/Divyesh/Demos/MvvmCodeFirst/MvxPlus1DaysOfMvvmCross/Mvx-00-FirstDemo/FirstDemo.iOS/Views/FirstView.cs:36

Bingo

This is a duplicate of https://github.com/MvvmCross/MvvmCross/issues/2952 - please avoid creating duplicate issues
Please can you reproduce this in the Playground sample (see source code - https://github.com/MvvmCross/MvvmCross/tree/develop/Projects/Playground) and submit as a PR so we can investigate

@nickrandolph I'm trying to figure it out back since few days, I have not get any solution till yet!

Still, I'm unable to figure out the solution!

That may be true but see my request - if you want to accelerate the provision of solution, can we ask that you provide a PR that demonstrates the issue.

@nickrandolph I have take the fork of https://github.com/nickrandolph/MvxPlus1DaysOfMvvmCross
and made the changes but it not allow me to push the changes I have done for PR.

@divyesh008 you didn't fork it. You just clone it. According to GitHub there is no forks.

git_scr

Actually, I have made the PR in this sample solution! please check it.

I've spent the last 30mins or so grappling with this issue. I believe it's due to changes made in #2682.

As there is now a binding to UITextField.EditingDidEnd, we need to ensure it is not stripped by the linker. The solution is to make sure your LinkerPleaseInclude.cs file contains the following:

public void Include(UITextField textField)
{
    textField.Text = textField.Text + "";
    textField.EditingChanged += (sender, args) => { textField.Text = ""; };
    textField.EditingDidEnd += (sender, args) => { textField.Text = ""; };
}

@jamespettigrew Thank you for the answer, it worked for me too.

I was going to make a PR to update LinkerPleaseInclude on the iOS side but it looks like this was already accomplished in #2843.

@Cheesebaron @divyesh008, this issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings