Aidan
Aidan

Reputation: 4891

Using an F# library in a C# project in Xamarin

I have a solution in Xamarin Studio with a C# console program trying to call an F# library.

The reference is fine, everything builds.

My F# code looks like the following:

namespace MyStore.Library

module public Lookup =

    open System

    let lookup name (age:int) =
        String.Format("{0}, {1}", name, age.ToString() );

I can call the F# library from an F# console and a C# library from the C# console, but I can't mix the two.

The C# console doesn't see any F# namespaces at all.

What am I doing wrong?

What should I do to see the F# namespace from C#?

Upvotes: 5

Views: 423

Answers (1)

Ming-Tang
Ming-Tang

Reputation: 17651

In the C# project, you need to add a reference to your F# project.

In the Solution pane, expand your project, and click the gear icon -> Edit References

Then go to Projects tab, check the F# project you want to reference to, then click OK.

edit references projects

Also, make sure both C# and F# project target to the same .NET framework! To check that, right click a project, Options -> Build -> General

right click projects target

Upvotes: 2

Related Questions