Skip to content

PropertyBinderImplementation.OneWayBind crash - System.InvalidCastException: Specified cast is not valid. #2466

@DawidBester

Description

@DawidBester

Describe the bug

App crash after upgrading ReactiveUI packages from 11.4.17 to 11.5.1

Steps To Reproduce

Upgrade ReactiveUI packages to 11.5.1
Run code, my app crash in OneWayBind, code as follows:

this.OneWayBind(ViewModel, vm => vm.IsReadOnly, x => x.ExportName.IsEnabled,
arg =>
{
if (arg)
return false;
else return true;
})
.DisposeWith(disposable);

Crash message

PropertyBinderImplementation.OneWayBind[TViewModel,TView,TProp,TOut] (TViewModel viewModel, TView view, System.Linq.Expressions.Expression1[TDelegate] vmProperty, System.Linq.Expressions.Expression1[TDelegate] viewProperty, System.Func`2[T,TResult] selector)
d:\a\1\s\src\ReactiveUI\Bindings\Property\PropertyBinderImplementation.cs, line 220
System.InvalidCastException: Specified cast is not valid.

Stack trace
(wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
PropertyBinderImplementation.OneWayBind[TViewModel,TView,TProp,TOut] (TViewModel viewModel, TView view, System.Linq.Expressions.Expression1[TDelegate] vmProperty, System.Linq.Expressions.Expression1[TDelegate] viewProperty, System.Func2[T,TResult] selector) d:\a\1\s\src\ReactiveUI\Bindings\Property\PropertyBinderImplementation.cs:220 PropertyBindingMixins.OneWayBind[TViewModel,TView,TProp,TOut] (TView view, TViewModel viewModel, System.Linq.Expressions.Expression1[TDelegate] vmProperty, System.Linq.Expressions.Expression1[TDelegate] viewProperty, System.Func2[T,TResult] selector) d:\a\1\s\src\ReactiveUI\Bindings\Property\PropertyBindingMixins.cs:329
JournalCreateExport.b__6_0 (System.Reactive.Disposables.CompositeDisposable disposable) D:\Data\Projects**********\Views\JournalCreateExport.xaml.cs:146
ViewForMixins+<>c__DisplayClass9_0.b__0 () d:\a\1\s\src\ReactiveUI\Activation\ViewForMixins.cs:238
ViewForMixins+<>c__DisplayClass10_0.b__0 (System.Boolean activated) d:\a\1\s\src\ReactiveUI\Activation\ViewForMixins.cs:255
AnonymousSafeObserver1[T].OnNext (T value) /_/Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:43 Sink1[TTarget].ForwardOnNext (TTarget value) //Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:49
DistinctUntilChanged2+_[TSource,TKey].OnNext (TSource value) /_/Rx.NET/Source/src/System.Reactive/Linq/Observable/DistinctUntilChanged.cs:72 Sink1[TTarget].ForwardOnNext (TTarget value) /
/Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:49
Merge1+Observables+_+InnerObserver[TSource].OnNext (TSource value) /_/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs:236 Subject1[T].OnNext (T value) /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:148
ActivationForViewFetcher+<>c__DisplayClass3_1.g__Handler|6 (System.Object sender, System.EventArgs e) d:\a\1\s\src\ReactiveUI.XamForms\ActivationForViewFetcher.cs:65
Page.SendAppearing () D:\a\1\s\Xamarin.Forms.Core\Page.cs:435
PageRenderer.OnAttachedToWindow () D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:68
View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.39(intptr,intptr)

Expected behavior

Code should not crash and function the same as before the upgrade

Screenshots

Environment

  • OS: Android 10
  • Version API Level 29
  • Device: Emulator
    Xamarin Forms 4.7.0.1179

Additional context

Downgrading all ReactiveUI packages to 11.4.17 fixes the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions