AwkwardCoder
AwkwardCoder

Reputation: 25631

Reactive Extensions support for WPF in .Net 5.0

I am trying to use DispatcherScheduler.Current in an example WPF app, the following line does not resolve the class (static).

Does anyone know why this not resolve?

 public partial class App : Application
 {
     public App()
     {
         **var tmp = DispatcherScheduler.Current;**
     }
 }

The csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Reactive" Version="5.0.0" />
  </ItemGroup>

</Project>

The following support issue on GitHub suggest this should work - here

OS: Mircosoft Windows 10 Pro, Version: 10.0.19042

Upvotes: 2

Views: 767

Answers (1)

Lukasz Szczygielek
Lukasz Szczygielek

Reputation: 3110

I made a fresh .NET 5 WPF project and I saw same issue. Adding nuget ReactiveUi solved missing DispatcherScheduler, but don't know why DispatcherScheduler is not available by referencing just System.Reactive.

Update:
I tested fresh project, but for .NET Core 3.1 WPF and everything is OK. It's issue with .NET 5.

Update 2:
I found issue on github https://github.com/dotnet/reactive/issues/1497, DispatcherScheduler is available for TFM net5.0-windows10.0.19041. I also used ILSpy to ensure that System.Reactive.dll is different for .net5.0 and net5.0-windows10.0.19041.
Changing TargetFramework in csproj to:

<TargetFramework>net5.0-windows10.0.19041</TargetFramework>

solves issue.

Upvotes: 2

Related Questions