Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rx 5 and .NET 5 for WPF application #1423

Closed
laurentkempe opened this issue Nov 11, 2020 · 5 comments
Closed

Rx 5 and .NET 5 for WPF application #1423

laurentkempe opened this issue Nov 11, 2020 · 5 comments

Comments

@laurentkempe
Copy link

I am trying to migrate a WPF application from .NET Core 3.1 with Rx 4.4.1 to .NET 5 and Rx 5.0.0
I am facing the following compilation issues

[CS0246] The type or namespace name 'DispatcherScheduler' could not be found (are you missing a using directive or an assembly reference?)
[CS1061] 'IObservable<long>' does not contain a definition for 'ObserveOnDispatcher' and no accessible extension method 'ObserveOnDispatcher' accepting a first argument of type 'IObservable<long>' could be found (are you missing a using directive or an assembly reference?)

I have read the v5.0 changes and #1315 and adapted my csproj as @clairernovotny recommended it:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows10.0.19041</TargetFramework>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
    <LangVersion>9.0</LangVersion>
    <OutDir>..\..\Output\</OutDir>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Reactive" Version="5.0.0" />
    <PackageReference Include="System.Reactive.Linq" Version="5.0.0" />
</Project>

but still get those compilation errors. So, what am I doing wrong?

I am also a bit confused by the sentence ".NET 5 with the Windows 10 19041 SDK (able to target earlier Windows versions)" on the README

What do I need to do if I want to have my application supported on Windows version supported by .NET 5 except Windows 7 SP1

OS Version Architectures Lifecycle
[Windows Client][Windows-client] 7 SP1(*), 8.1 x64, x86 [Windows][Windows-lifecycle]
[Windows 10 Client][Windows-client] Version 1607+(**) x64, x86, Arm64 [Windows][Windows-lifecycle]
[Windows Server][Windows-Server] 2012 R2+ x64, x86 [Windows Server][Windows-Server-lifecycle]
[Windows Server Core][Windows-Server] 2012 R2+ x64, x86 [Windows Server][Windows-Server-lifecycle]
[Nano Server][Nano-Server] Version 1809+ x64 [Windows Server][Windows-Server-lifecycle]

Thanks for your appreciated help!

@clairernovotny
Copy link
Member

You should not need a reference to System.Reactive.Linq, those are old type forwarders.

This works for me:

using System;
using System.Reactive.Concurrency;

namespace ClassLibrary4
{
    public class Class1
    {
        public Class1()
        {
            DispatcherScheduler scheduler;
        }
    }
}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows10.0.19041</TargetFramework>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
    <LangVersion>9.0</LangVersion>
    <OutDir>..\..\Output\</OutDir>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Reactive" Version="5.0.0" />
  </ItemGroup>
</Project>

@laurentkempe
Copy link
Author

You should not need a reference to System.Reactive.Linq, those are old type forwarders.

Oh ok, I could remove that reference without any issue 👍

I tried in a simplified WPF project and it didn't work at first, but when I loaded it in VS 16.8 it is worked! So, it seems that my problem was not coming from Rx but from Rider EAP! Adn after loading my full project into VS I could also compile it! Thanks a lot @clairernovotny

So, with those settings, would it mean that my WPF app would work on all .NET 5 supported version of Windows?

@clairernovotny
Copy link
Member

So, with those settings, would it mean that my WPF app would work on all .NET 5 supported version of Windows?

Yes

@laurentkempe
Copy link
Author

Fantastic @clairernovotny again BIG thanks to you for your major help!
It took us quite some work to go from .NET Framework to .NET Core 3.1 and couple of hours to .NET 5 😄

@a44281071
Copy link

a44281071 commented May 10, 2022

Can't find ObserveOnDispatcher().
Lost 'Framework assembly' for nuget package 'System.Reactive'

ok target:
framework:
net480/net5.0-windows10.0.19041

error target:
OS: win7_sp1
framework:
net461/net5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants