Home Dashboard Directory Help

Cannot add reference to portable F# library from portable C# library by miegirl



Sign in
to vote
Type: Bug
ID: 761306
Opened: 9/5/2012 12:18:54 PM
Access Restriction: Public
User(s) can reproduce this bug


Visual Studio 2012 RTM does not allow to add references to portable F# libary projects from portable C# library projects via the Add Reference dialog. Even when target profiles match.

It compiles perfect when project reference added manually into the csproj file (via ProjectReference element) but displays the "Unable to add a reference to project 'Projectname'" warning and marks the reference with yellow exclamation mark.
Sign in to post a comment.
Posted by Rich Turner [Bitcrazed] on 5/9/2014 at 3:15 PM
Sadly, this issue continues to persist in Visual Studio 2013 Update 2!!

I asked StackOverflow how to overcome this issue, but nobody appears to know how: http://stackoverflow.com/questions/23111782/how-do-i-add-a-reference-to-f-portable-library-from-c-sharp-portable-class-libr

Is anyone from Microsoft able/willing to comment?
Posted by John Lewicki (outlook.com) on 10/28/2013 at 1:05 PM
Sadly this appears to still be an issue in Visual Studio 2013. Fortunately the posted workaround still works, but it is most vexing to have that yellow exclamation mark cheekily taunting you from the References list.
Posted by miegirl on 4/18/2013 at 11:02 PM
The issue still persists in VS 2012 update 2.

For JohannesRudolph I post details on how to add reference manually in workarounds, be sure to follow this instruction (it looks bad however since line breaks are not preserved there).
Posted by JohannesRudolph on 4/17/2013 at 1:16 AM
Also: Contrary to the opener of this bug, I cannot get the reference to work properly even if I add the assembly reference manually by adding the project reference to the csproj file. I can use F# code from the C# assembly without problems, but the manually added reference is not displayed in the "References" section of the C# project in Solution Explorer and IntelliSense is not working for using the classes exposed by the F# assembly.
Posted by JohannesRudolph on 4/17/2013 at 1:12 AM
I can confirm this issues still persists, using Visual Studio 2012 SP1. Even if I manually change both the F# and C# portable library project to use TargetFrameworkProfile 47 the issue still persists.
Posted by miegirl on 2/11/2013 at 10:47 PM
No, the problem reproduces when both F# and C# use profile 47. I have stated this in description by the words "Event when target profiles match".
Posted by Microsoft on 2/11/2013 at 3:15 PM
Thank you for your feedback. It seems the problem you are experiencing is due to the fact that F# portable libaries only support profile 47. If you manually change to a different profile, some behaviors may work, but this is not a scenario that we have tested or support.

The recommended way to use F# portable libraries from C# portable libraries is to make both of them use Profile 47.
Posted by Microsoft on 9/5/2012 at 10:44 PM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 9/5/2012 at 12:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by miegirl on 4/18/2013 at 11:00 PM
How to add reference manually:

0. Consider that you have solution with two projects: Port.FS (F# port. library) and Port.CS (C# port. library).
1. Unload both projects.
2. Open Port.FS.fsproj for editing and find its ProjectGuid. For example, it is e81386b6-daeb-45b3-ab75-c1610e2f3ed5 in my case.
3. Open Port.CS.csproj for editing and add the following into any ItemGroup section:

    <ProjectReference Include="<relative path to fsproj>">
     <Project>{<F# project guid>}</Project>
     <Name><F# project name></Name>

In my case, for example, I add:

    <ProjectReference Include="..\Port.FS\Port.FS.fsproj">

Be sure to enclose F# project guid in figure braces.

4. Reload projects and use the reference. 1 warning appear in error list now: "Unable to add reference to project 'Port.FS'" and Port.FS appear with yellow exclamation mark in Port.CS references, but it can be ignored.
Posted by Rei Miyasaka on 11/7/2012 at 5:32 PM
Shocking how few people have noted this two months in...