Is it possible to mix .cs (C#) and .fs (F#) files in a single Visual Studio Windows Console Project? (.NET)


Question

How to do it? Is it possible to call a function from one F# code into C# without using a separated dll file or project?

1
26
1/21/2009 5:44:53 PM

Accepted Answer

You can't include two different languages in the same project, but you can merge them using ilmerge. To do this, put both projects in the same solution and reference the F# module as you would any dll. As part of your deployment script, run ilmerge to combine the exe file and dll file into a single exe file. See this Code Project article that details how to use ilmerge to create an exe.

21
1/21/2009 7:22:31 PM

Not being able to mix C# and F# in the same project creates a problem; It leads to circular dependencies between the two projects. Conceptually there is only one project containing two languages, but because of the way visual studio manages projects languages cannot be mixed, leading to circular dependencies.

For now the only solution I see it to create a lot of interfaces in a third project and have one of the project refer to the interfaces project, instead of the real project. Is there a better way?

Kind Regards, Nick


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon