0

I have decided to learn ReactiveUI after seeing what can be done with it, but my enthusiasm has been broken at the first attempt to run a simple project. I have recreated the example from this article, using reactiveui-winforms.Net40 version 6.5.0 from NuGet. Everything compiles ok, but i get an exception during runtime at the following line

var OKCmdObs = this.WhenAny(vm => vm.EnteredText,
            s => !string.IsNullOrWhiteSpace(s.Value));



System.InvalidOperationException occurred
  HResult=-2146233079
  Message=The current thread has no Dispatcher associated with it.
  Source=System.Reactive.Windows.Threading
  StackTrace:
       at System.Reactive.Concurrency.DispatcherScheduler.get_Current()
       at ReactiveUI.PlatformRegistrations.<>c.<Register>b__0_7() in C:\workspace\git-perso\ReactiveUI\ReactiveUI\Platform\Registrations.cs:line 75
  InnerException: 

Does anyone have any idea of what's happening ? The mentioned article does not have the compiled project available for download, and i didn't find any complete "Hello-World" project for reactiveui-winforms.


My test project can be downloaded here.


In Visual Studio, if i Continue(F5), another exception occures :

System.NullReferenceException occurred
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=ReactiveUI
  StackTrace:
       at ReactiveUI.IROObservableForProperty.<>c__DisplayClass1_0.<GetNotificationForProperty>b__6(IReactivePropertyChangedEventArgs`1 x) in C:\workspace\git-perso\ReactiveUI\ReactiveUI\IROObservableForProperty.cs:line 44
  InnerException: 

If i continue to hit F5 i get :

    System.Exception was unhandled by user code
  HResult=-2146233088
  Message=An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
  Source=ReactiveUI

1 Answers1

0

This exception is caused because RxUI always tries to initialize for WPF, even though (because you're also using the winforms package) it'll override this setting with a Winforms-based scheduler right after.

It should be harmless though, as it's catched and ignored. You're probably hitting it within VS ?

Gluck
  • 2,933
  • 16
  • 28
  • Yes it happens in VS. I think the first exception is indeed catched(by whom?) , but further i get another exception; see my updated question. – francezu13k50 Mar 22 '16 at 13:10
  • Can't reproduce that, your project works fine after the initial exception, maybe you changed something ? – Gluck Mar 22 '16 at 14:46
  • That's odd. I've tested my uploaded project on a different computer (running W7 instead of W8.1) and i get the same result. Also the compiled application gives `NullReferenceException` on all tested SO's (W8.1, W7, WinXp). – francezu13k50 Mar 22 '16 at 17:18