Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] WhenActivated/WhenAnyObservable are throwing InvalidCastException in v12.1.1/v12.1.4 #743

Closed
yjagota opened this issue Aug 8, 2021 · 1 comment · Fixed by #745
Closed

Comments

@yjagota
Copy link

yjagota commented Aug 8, 2021

Describe the bug
Any use of WhenActivated/WhenAnyObservable in any ReactiveObject is throwing the following exception:

System.InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'ReactiveUI.IActivationForViewFetcher'.
   at System.Runtime.CompilerServices.CastHelpers.ChkCastAny(Void* toTypeHnd, Object obj)
   at System.Linq.Enumerable.<CastIterator>d__64`1.MoveNext()
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
   at ReactiveUI.ViewForMixins.<>c.<.cctor>b__1_0(Type t, Object _) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Activation\ViewForMixins.cs:line 24
   at Splat.MemoizingMRUCache`2.Get(TParam key, Object context) in D:\a\splat\splat\src\Splat\MemoizingMRUCache.cs:line 138
   at Splat.MemoizingMRUCache`2.Get(TParam key) in D:\a\splat\splat\src\Splat\MemoizingMRUCache.cs:line 114
   at ReactiveUI.ViewForMixins.WhenActivated(IActivatableView item, Func`1 block, IViewFor view) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Activation\ViewForMixins.cs:line 149
   at ReactiveUI.ViewForMixins.WhenActivated(IActivatableView item, Action`1 block, IViewFor view) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Activation\ViewForMixins.cs:line 226
   at NovusPrime.Views.Controls.AuthorizationControl..ctor() in D:\Projects\Novus\NovusPrime\NovusPrime\Views\Controls\AuthorizationControl.xaml.cs:line 30
System.InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'ReactiveUI.IActivationForViewFetcher'.
   at System.Runtime.CompilerServices.CastHelpers.ChkCastAny(Void* toTypeHnd, Object obj)
   at System.Linq.Enumerable.<CastIterator>d__64`1.MoveNext()
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
   at ReactiveUI.ReactiveNotifyPropertyChangedMixin.<>c.<.cctor>b__1_0(ValueTuple`3 t, Object _) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Mixins\ReactiveNotifyPropertyChangedMixin.cs:line 23
   at Splat.MemoizingMRUCache`2.Get(TParam key, Object context) in D:\a\splat\splat\src\Splat\MemoizingMRUCache.cs:line 138
   at Splat.MemoizingMRUCache`2.Get(TParam key) in D:\a\splat\splat\src\Splat\MemoizingMRUCache.cs:line 114
   at ReactiveUI.ReactiveNotifyPropertyChangedMixin.NotifyForProperty(Object sender, Expression expression, Boolean beforeChange, Boolean suppressWarnings) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Mixins\ReactiveNotifyPropertyChangedMixin.cs:line 208
   at ReactiveUI.ReactiveNotifyPropertyChangedMixin.NestedObservedChanges(Expression expression, IObservedChange`2 sourceChange, Boolean beforeChange, Boolean suppressWarnings) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Mixins\ReactiveNotifyPropertyChangedMixin.cs:line 189
   at ReactiveUI.ReactiveNotifyPropertyChangedMixin.<>c__DisplayClass4_1`2.<SubscribeToExpressionChain>b__4(IObservedChange`2 y) in D:\a\ReactiveUI\ReactiveUI\src\ReactiveUI\Mixins\ReactiveNotifyPropertyChangedMixin.cs:line 152
   at System.Reactive.Linq.ObservableImpl.Select`2.Selector._.OnNext(TSource value) in /_/Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs:line 39

Steps To Reproduce:

  • Create minimal application with ReactiveUI using WPF/.Net 5.0 with Splat.Autofac.
  • In constructor of a ReactiveUserControl, try this.WhenActivated(d =>{});

Environment:

  • OS: Windows 10 19042.110
  • Net 5.0.8
  • Splat.Autofac v12.1.1 or v12.1.4
  • Autofac v6.2.0

Additional context
Works fine with Splat.Autofac v11.1.1

@yjagota yjagota changed the title [BUG] Summary of item [BUG] WhenActivated/WhenAnyObservable are throwing InvalidCastException in v12.1.1/v12.1.4 Aug 8, 2021
@ChrisPulman ChrisPulman linked a pull request Aug 10, 2021 that will close this issue
2 tasks
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant