1

I have a viewmodel where I'm trying to use WhenActivated to dispose:

    this.WhenActivated(disposables => 
    {
                       this.WhenAnyValue(x => x.Selected)
                        .WhereNotNull()
                        .ObserveOn(RxApp.MainThreadScheduler)
                        .Do(x => _logger.LogInformation($"selected {x?.Name}"))
                        .Subscribe(x => process(x))
                        .DisposeWith(disposables);
    });

And I get the error:

MyViewModel.cs(59, 22): [CS0121] The call is ambiguous between the following methods or properties: 'System.Reactive.Disposables.DisposableMixins.DisposeWith(T, System.Reactive.Disposables.CompositeDisposable)' and 'Avalonia.Controls.Mixins.DisposableMixin.DisposeWith(T, System.Reactive.Disposables.CompositeDisposable)'

3
  • 1
    Well, which of those extension methods did you expect to call? Perhaps you should remove a using directive for either System.Reactive.Disposables or Avalonia.Controls.Mixins? (If only one of those namespaces is imported, the call won't be ambiguous.) Commented Mar 31, 2023 at 9:23
  • @JonSkeet intended to use the former, but I realize I was focusing on looking in the ViewForMixins extensions provided by ReactiveUI for the correct method as indicated by the intellisense and not reading the error message properly. Commented Mar 31, 2023 at 9:44
  • 1
    I honestly don't know how to understand that comment... but this is a good example of why a minimal reproducible example is useful, including what you expect to happen. Commented Mar 31, 2023 at 9:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.