Why can't I reference `FSharpOption<>` within my C# PCL for Xamarin.Android.

ScottNimrodScottNimrod USMember ✭✭
edited September 2016 in Xamarin.Android

I am unable to reference FSharpOption<> within my C# PCL project targeting Xamarin.Android.

The error I receive is the following:

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

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

NOTE:

My C# project DOES reference FSharp.Core. It is referencing the same FSharp.Core version that my F# projects are using:

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

Adding an App Config

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

The app.config is the following:

<?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 anyone provide me guidance on the steps required to reference FSharp.Core functionality within my C# project?

UPDATED

I have another class that successfully references FSharp.Core within 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 code above does not appear to cause any compile errors. Again, this file is in the same project as my other file that does cause errors.

The code that causes errors is the following:

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

NOTE:
The using statement for FSharp.Core appears to be ignored.

My viewmodel is hosted within an F# project.

Answers

Sign In or Register to comment.