0

So I'm developing a small F# console app in VS2010, targeting .Net 3.5. Seeing as there are some nice helpers I tried to add a reference to Fsharpx.Core through NuGet.

It compiled with a warning:

Found conflicts between different versions of the same dependent assembly.

...and when executing I got the following:

Could not load file or assembly 'FSharp.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Now, I don't think I have F# 3.0 installed. Does FSharpx require F# 3.0? If so, does that mean I can't use FSharpx in VS2010? (Since F# 3.0 can't be used in VS2010.)

In that case, is there a version of FSharpx for F# 2.0? Or am I missing something?

Edit: More info on F# library versions: Correct version of Fsharp.Core and F# compiler and runtime version number confusion.

Community
  • 1
  • 1
johv
  • 4,424
  • 3
  • 26
  • 42
  • Yes, FSharpx requires FSharp.Core 2.3 / 4.3. You can work with this in VS2010, see https://github.com/fsharp/fsharpx/issues/260#issuecomment-24937340 , you might need a binding redirect too. – Mauricio Scheffer Dec 11 '13 at 15:28
  • Oh, that sucks. Isn't there any version FSharpx for F# 2.0? Wasn't FSharpx around before F# 3.0? Or would it be pointless to use such an old version? – johv Dec 11 '13 at 22:51
  • Yes, FSharpx used to target FSharp.Core 2.0/4.0 but it doesn't matter. – Mauricio Scheffer Dec 11 '13 at 23:41

1 Answers1

0

In the end I ended up doing a F# 2.0-targeting build of Fsharpx.Core myself.

This is what i did:

  1. Fetch latest source from GitHub.
  2. Open FSharpx.Core.fsproj, creating a new solution for only this one.
  3. Change references to use old version (2.0.0.0) of FSharp.Core
  4. Build!

And this worked, solving my problems above.

Could this be working because the FSharpx source helpfully includes a F# 3.0-compiler?

Kind of like how you can use some new features in C# (like optional arguments) but still target .NET 3.5, by using a newer (from .NET 4) compiler?

johv
  • 4,424
  • 3
  • 26
  • 42
  • 1
    I recommend against doing this. You don't need the F# 3.0 compiler just because FSharpx uses FSharp.Core 2.3 / 4.3. FSharp.Core.dll is just another library. – Mauricio Scheffer Dec 11 '13 at 23:40
  • I used the F# 3.0 compiler to build FSharpx since that's what was included in the build. Also, I thought that FSharpx might be using some new F# 3.0-feature (like member val or whatever). After getting a new dll I keep using the same old F# 2.0 compiler as before for my own project. – johv Dec 12 '13 at 00:37
  • @MauricioScheffer Is this what you recommend against doing? And in that case, will FSharp.Core 2.3 work as drop-in replacement for FSharp.Core 2.0 even in my own project? Will the F# 2.0 compiler happily compile my F# 2.0-code and link it to the F# 3.0 dll instead? If it isn't obvious, I'm quite new to F#, hehe. – johv Dec 12 '13 at 09:19
  • What I recommend against is downgrading FSharpx to FSharp.Core 2.0. Instead, set a binding redirect to use FSharp.Core.dll 2.3 at runtime. – Mauricio Scheffer Dec 12 '13 at 18:44
  • May I ask why? Seems like it compiled just fine. Should I expect problems anyway? Also, what if my codes runs as a plugin in another application, so that I'm unable to edit app.config? (Can't add binding redirect, right?) – johv Dec 12 '13 at 21:51
  • The problem is you'll have to maintain that fork of FSharpx... for no good reason. If you're not the author of the app, you can distribute your library as a NuGet package, which should add the binding redirect as needed http://docs.nuget.org/docs/release-notes/nuget-1.2#Automatically_Add_Binding_Redirects – Mauricio Scheffer Dec 12 '13 at 23:56
  • Ah, I see what you mean, it's a fork indeed. It's a plugin for a commercial app. Like an Excel-addin. Can I use NuGet with Excel? Also, as you're saying a binding redirect would work, does that mean 2.3 is indeed a drop-in replacement for 2.0? – johv Dec 13 '13 at 10:35
  • Yes, 2.3 is a drop-in replacement for 2.0, which is why binding redirects work without issues. – Mauricio Scheffer Dec 13 '13 at 14:18
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43135/discussion-between-johv-and-mauricio-scheffer) – johv Dec 13 '13 at 15:07
  • When can't you use redirects and why? – Mauricio Scheffer Dec 13 '13 at 15:08
  • By redirects I assume you are referring to editing the app.config-file? While this is a small console application I often write .NET-plugins (in C#) for big proprietary applications, supplying a dll that's loaded by the app. In this case, I don't have control over the app.config of the main exe. – johv Dec 13 '13 at 15:14
  • I already explained how to work around that: http://stackoverflow.com/questions/20521117/using-fsharpx-from-nuget-with-f-2-0-in-vs2010/20531749?noredirect=1#comment30743748_20531749 – Mauricio Scheffer Dec 13 '13 at 15:17
  • Are you referring to the [blog post](http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html) referencing [MSDN on binding redirects](http://msdn.microsoft.com/en-us/library/twy1dw1e.aspx) that talks about editing the "web.config (or app.config)"? In that case, I still can't edit the config file, as it might cause problems with the main app, and my users might not even have the rights to edit that file. Or are you saying I should use OpenWrap which is also mentioned in the blog? – johv Dec 13 '13 at 15:30
  • No OpenWrap. Sorry, that's as much time as I can put into this question. Take a good look at the pointers I gave... – Mauricio Scheffer Dec 13 '13 at 15:42
  • So I take it the answer is "edit app.config or you're on your own"? I also fail to see how to use NuGet for Excel... Oh well. But thanks for your time anyway! – johv Dec 13 '13 at 15:49
  • Sorry, my bad, I missed the part where you said it was a plugin for Excel. No idea how to deal with that. – Mauricio Scheffer Dec 13 '13 at 16:17