Skip to content

[BUG] Unit testing .NET Core WPF applications fails with TypeLoadException #2194

@anaisbetts

Description

@anaisbetts

Describe the bug

Unit testing .NET Core WPF apps doesn't work because getting MainThreadScheduler blows up even though we're in a test runner.

  Message: 
    System.TypeInitializationException : The type initializer for 'ReactiveUI.RxApp' threw an exception.
    ---- System.TypeLoadException : Could not load type 'System.Reactive.Concurrency.DispatcherScheduler' from assembly 'System.Reactive, Version=4.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'.
  Stack Trace: 
    RxApp.get_MainThreadScheduler() line 138
    MainWindowViewModel.ctor(IObservable`1 allAppWindows) line 49
    SmokeTests.MainWindowViewModelShouldBeCreatableInRunner() line 13
    ----- Inner Stack Trace -----
    <>c.<Register>b__0_7()
    WaitForDispatcherScheduler.AttemptToCreateScheduler() line 67
    WaitForDispatcherScheduler.ctor(Func`1 schedulerFactory) line 35
    Registrations.Register(Action`2 registerFunction) line 37
    DependencyResolverMixins.ProcessRegistrationForNamespace(String ns, AssemblyName assemblyName, IMutableDependencyResolver resolver) line 120
    <>c__DisplayClass0_0.<InitializeReactiveUI>b__2(String ns) line 47
    CompatMixins.ForEach[T](IEnumerable`1 this, Action`1 block) line 16
    DependencyResolverMixins.InitializeReactiveUI(IMutableDependencyResolver resolver) line 48
    <.cctor>b__9_0() line 87
    InternalLocator.RegisterResolverCallbackChanged(Action callback) line 120
    Locator.RegisterResolverCallbackChanged(Action callback) line 74
    RxApp.cctor() line 89

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions