简体   繁体   中英

Using F# portable class library from C# portable library

I have a WPF application that uses a F# library for calculations. I'm trying to refactor so that I have WPF Application -> C# Portable Class Library (models) -> F# Portable Class Library (calculations).

My end goal is to use Xamarin Forms to put a UI on it that I can use on other platforms. This is currently mostly an experiment to assess the viability of the approach.

Every time I try to add a reference to the F# library from the C# library, I get an error message that says "Unable to add reference to X, Portable class libraries can only reference other portable class libraries".

I can reference either library from the WPF project and I've tried every permutation that I can think of to make it work.

There are quite a few similar questions, but they either don't have an answer or state that it is fixed in VS 2013. It doesn't seem to work in VS 2015 Update 2.

Does anyone have a link to a sample that works, or a workaround to get past the problem?

Steps for VS 2015 Update 2:

  1. Create new(tested with new solution) Class Library (Portable)
  2. As target choose only Windows 10 or Windows 8.1(maybe other target would work too - haven't tested though)
  3. Add F# Portable Library(tested with .Net 4.5, Windows Store, Xamarin and with .Net 4.5, Windows Store, Silverlight 5, Xamarin)
  4. Now you can reference F# library without any errors
  5. Now You can change properties of C# project(Right click on c# project and choose properties) to match the targets You would like to have (Section Library, subsection Targeting)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM