Can you mix .net languages within a single project?

Can you mix .net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files.

For both web and apps?

In particular I'd be interested in F# and C#.


You can mix languages in a single assembly with ILMerge and MSBuild.

Here is a very good example about it.


Yes, you can, but Visual Studio does not support it directly. What you will do is compile code to netmodules, then combine them into a single assembly. The compilers support the "/target:module" option which generates these netmodules.

You can then use the compilers to reference other netmodules when building, or use Assembly Linker (Al.exe). There's even an msbuild task for it: AL (Assembly Linker) Task.

A full overview is provided on MSDN: How to: Build a Multifile Assembly


CMS mentions an interesting approach, but in reality I would suggest you keep things simple and have different assemblies (projects) for the C# and F# code. There are well documented communication points between C# and F# (such as here and here) - I'd recommend them instead. The differences between C# and F# (especially with F# having a different runtime!) are quite large...


you can specify the language in each assembly project (library DLL) and use several of these in the same solution, but i don't think you can mix languages within the same assembly


You can do it in a web site project versus a compile-first project: http://www.aspnetlibrary.com/articledetails.aspx?article=Use-C-Sharp-and-VB.NET-in-the-same-project. A web site's BuildProvider resolves language elements on-the-fly.

.NET's BuilderProvider still isn't available for non-web site projects so you're out of luck for standard app mixed Intellisense.