I have problems creating F# portable project which than should be referenced from C# portable project. When adding such reference, the following message appears:
Unable to add a reference to 'PortableLibrary1'. Portable Library projects can only reference other Portable Library projects and assemblies.
The problem is easily reproduced using latest Visual Studio 2015 Update 1 (version 14.0.24720.00). I also have Xamarin installed.
I can reproduce the problem using any kind of C# portable project with following available:
- Class Library (Portable)
- Class Library (Portable for iOS, Android and Windows)
and with any kind of F# portable library project with following available:
- Portable Library (.NET 4.5, Windows Store, Silverlight 5, Xamarin) [Profile 47]
- Portable Library (.NET 4.5, Windows Store, Windows Phone 8 Silverlight, Xamarin) [Profile 78]
- Portable Library (.NET 4.5, Windows Store, Windows Phone 8.1, Windows Phone Silverlight 8, Xamarin) [Profile 259]
- Portable Library (.NET 4.5, Windows Store, Xamarin) [Profile 7]
I've used the same profiles for C# as for F# and nothing helps.
Seems like there already was a such issue before (How do I add a reference to F# Portable Library from C# Portable Class Library (PCL)) which then was successfully fixed. But it is now reproduced again.
Can somebody please tell me am I missing something? Maybe there is something which needs to be additionally installed or so?
If there is indeed a bug and you want to call something from the C# PCL library into the F# PCL one, a way to work arround that could be to add the C# library as a reference to the F# library instead (the other way arround).
Then the F# code will implement an interface (see https://msdn.microsoft.com/en-us/library/dd233207.aspx) that you define at the C# side.
It will also call a method you provide at the C# side to give you a reference of a class instance that implements the interface (that is implemented at the F# side). Alternatively you can use MEF (Managed Extensibility Framework - https://blogs.msdn.microsoft.com/jomo_fisher/2010/03/09/neat-samples-extend-your-f-program-with-mef/) to pass that interface implementation from the F# side to the C# side, with the C# side initiating the request for the "binding" (also read about Inversion of Control / Dependency Injection)
I just had the same issue. I solved it with hacking the .csproj of my PCL. After that the F# PCL is referenced in the C# project and I can use everything. I don't know if there are any problems - I could not figure out any.
Here are the steps to reproduce:
edit C# .csproj and add following itemgroup
I'm using Visual Studio 2015 Community with Update 2