" in a C # project I can't reference FSharpOption<> in my C # PCL project targeting Xamarin.Android in Visual Stud...">

Cannot reference "FSharpOption <>" in a C # project

I can't reference FSharpOption<> in my C # PCL project targeting Xamarin.Android in Visual Studio 2015.

Here's a video that shows the steps I'm trying to solve.

The error I am getting is the following:

The type FSharpOption<> is defined in an assembly that is not referenced. You must add an assembly link

FSharp.Core, Version=3.7.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Note:

My C # project has an FSharp.Core link. It refers to the same version of FSharp.Core as my F # projects:

 some_path\packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll 

Adding Application Configuration

The app.config file that I placed in my Android client project is the same app.config file that I use in my test project written in F #.

The app.config application is as follows:

 <?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.4.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 

Can someone give me guidance on the steps needed to reference FSharp.Core functionality in my C # project?

UPDATED

I have another class that successfully references FSharp.Core as part of the same C # project:

 static class Utility { public static bool IsSome(this FSharpOption<string> option) => FSharpOption<string>.get_IsSome(option); public static bool IsNone(this FSharpOption<string> option) => FSharpOption<string>.get_IsNone(option); } 

The above code does not cause compilation errors. Again, this file is in the same project as my other file, which is causing errors.

The error code is as follows:

 using Microsoft.FSharp.Core; // . . . if (_viewModel.FamilySummary.IsSome()) { } 

Note:
The using statement for FSharp.Core seems to be ignored.

My viewmodel is hosted inside an F # project inside Visual Studio.

+6
source share
3 answers

I solved the problem by adding the actual dll file to my client project and then linking the link to my dll client.

enter image description here

+2
source

When I came across a similar problem, the solution was to remove FSharp.Core from both projects (C # and F # 1) and then install it again, but using the NuGet package manager to solve it (not for every project).

So, after removing FSharp.Core from both, go to Tools> NuGet Package Manager> Managing NuGet Packages to solve ...

Find FSharp.Core here, check all the projects you want to add the library to, and select the version you want to add.

This solved this problem for me.

Edit: Another thing worth checking out is that any library using FSharp.Core actually uses the same version as you.

+3
source

After changing the forwarding redirection in app.config you may also need to delete the obj folder in the executable project folder.

For some reason, an outdated configuration file may be located there and copied to your folders with folders, despite performing clean rebuilds.

+2
source

All Articles