【发布时间】:2016-03-22 08:41:43
【问题描述】:
在看到 ReactiveUI 可以做什么之后,我决定学习它,但是在第一次尝试运行一个简单的项目时,我的热情就被打破了。我使用来自 NuGet 的 reactiveui-winforms.Net40 版本 6.5.0 重新创建了 this 文章中的示例。一切编译正常,但我在运行时在以下行遇到异常
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:
有人知道发生了什么吗? 提到的文章没有可供下载的编译项目,我也没有找到任何完整的用于响应式 Winforms 的“Hello-World”项目。
我的测试项目可以下载here。
在 Visual Studio 中,如果我继续(F5),则会发生另一个异常:
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:
如果我继续按 F5,我会得到:
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
【问题讨论】:
标签: winforms visual-studio-2010 c#-4.0 reactiveui