Forum Xamarin Xamarin.Android

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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


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


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"?>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
        <bindingRedirect oldVersion="" newVersion="" />

Can anyone provide me guidance on the steps required to reference FSharp.Core functionality within my C# project?


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()) {

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

My viewmodel is hosted within an F# project.


Sign In or Register to comment.