Reputation: 4257
I have a Xamarin.IOS application and use MvvmCross and the ResxPlugin for translations. That workes without issues in debug. But since I updated from I guess 5.3.x to 5.6.3 the app crashes in release mode with the linker set to "Link Framework SDKs only" when I try to execute the following line:
bindingSet.Bind(textViewWelcomeMessage)
.For(txt => txt.Text)
.To(vm => vm.TextSource)
.WithConversion(new MvxLanguageConverter(), "WelcomeMessage");
This works without issues:
bindingSet.Bind(textFieldAgreementText)
.For(lbl => lbl.AttributedText)
.To(vm => vm.GeneralAgreementText)
.WithConversion("StringToHtml");
So I assume the problem lies somewhere in the MvxLanguageConverter in combination with textFields.
In my "LinkerPleaseInlude" file I have this added:
public void Include(UITextView textView)
{
textView.Text = textView.Text + "";
textView.AttributedText = new NSAttributedString();
textView.Changed += (sender, args) => { textView.Text = ""; };
}
The error message in the output is:
2018-01-24 09:37:39.415 ConnectContacts.Ios[27680:1063685] System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <6adc0d5857264558a9d45778a78ae02a>:0
at MvvmCross.Binding.iOS.Target.MvxUITextViewTextTargetBinding.SubscribeToEvents () [0x00053] in <614c9ef828c14ba687a40ec2656f480f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <866b1e46764b48aab0d408952a6f006f>:0
at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () [0x0003a] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
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 <866b1e46764b48aab0d408952a6f006f>: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 <866b1e46764b48aab0d408952a6f006f>: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 <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[TTarget].Apply () [0x0001f] in <866b1e46764b48aab0d408952a6f006f>:0
at MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[TOwningTarget,TSource].Apply () [0x00016] in <866b1e46764b48aab0d408952a6f006f>:0
at ConnectContacts.Ios.Views.Wizard.WelcomeView.ViewDidLoad () [0x001ae] in <b2a318752d5d4fbeb6d32a83c8b6f752>:0
--- End of stack trace from previous location where exception was thrown ---
Do I have to make something different with the new version?
Upvotes: 0
Views: 406
Reputation: 5182
You need to add the following to your LinkerPleaseInlude
for UITextView
textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";
See this GitHub issue
Upvotes: 2