Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird issues with RX on .NET 4.5 and F#

This is very odd.

I have two projects both F#. I've installed the latest stable (2.1.30214.0) release of RX via NUGET.

In on project everything is absolutely fine. In the other project I am basically getting errors everywhere because of the following.

Error   1   The type 'IObservable`1' is required here and is unavailable.
            You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, 
            Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.`

This really doesn't make sense as the source is fine and works perfectly in VS2010.

Any suggestions?

like image 375
Dave Avatar asked Jun 26 '13 00:06

Dave


3 Answers

As noted by @Mark Seemann, the problem stems from the fact that the Rx NuGet package for .NET 4.5 is actually a portable library.

Unfortunately, F# 3.0 doesn't support .NET 4.5-based portable libraries, only the legacy ones. Support for the newer portable libraries (also called .NETCore-based libraries) was added in VS 2013.

So, you have 2 options:

  • Build the Release45 or Debug45 target of Rx.sln in the Rx open-source release and use that instead of the Rx NuGet packages.

  • Use F# 3.1 which is available in Visual Studio 2013.

like image 87
lindydonna Avatar answered Nov 20 '22 11:11

lindydonna


I have the issue too, I fixed it by editing the fsproj and replacing Net45 with Net40 in all the reactive dll paths. This is required in spite of the following in my fsproj file:

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

Original answer:

My earlier fix made the project compile but I couldn't use RX (quite pointless) but is below.

The errors are coming from the line:

open System

Now I have:

//open System
type Array = System.Array
type Double = System.Double
type TimeSpan = System.TimeSpan

All works! Horribly ugly though, and it afflicts all files in the project.

like image 22
Lamarth Avatar answered Nov 20 '22 11:11

Lamarth


This happens when you reference the 4.5 DLLs in a 4.0 project or vice-versa. Make sure you're referencing the right version.

like image 1
Ana Betts Avatar answered Nov 20 '22 10:11

Ana Betts