Click here to Skip to main content
12,690,575 members (33,041 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ F# DLL
Hello ,
I need some help about dlls and interoperating. The problem is that i have to call a F# dll from c++ dll and use some F# functions, but not by using COM.

I searched for some kind of solution but i didn't manage to find one. I saw something intresting about mixed dlls but as far as i understand its for managed/unmanaged c++ code (please correct me if i am wrong). I though it will be a good idea to call the F# functions from c# dll (its way too easy), but the problem still remains (calling the functions from the new c# dll into the c++ dll)

My question is can you help me with ideas what i can do to be able to use few of the F# functions in the F# dll in my c++ project.

Thanks for your help :)
Posted 12-Sep-12 0:55am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Argonia -

Hello, this is my first attempt to answer a codeproject question. I would have liked to add pictures, but I will try to guide you the best I can.

In Visual Studio (I am using VS2010), Right Click on your C++ project and select the Properties menu item. Under Configuration Properties add Common Language Runtime Support by selecting Common Language Runtime Support(/clr) from the Common Language Runtime Support dropdown. Under Common Properties there is an "Add New Reference" button. Press this button and select the C# or F# project you would like to use.

In your C++ code add the following line
using namespace <the namespace of your .net project>;
using namespace TestLib;

I declared a static function in my Test class, so my call looks like

If you would like to call a member function you can use the following:
Test^ test = gcnew Test;
Mattias Högström 12-Sep-12 15:12pm
The F# language is a managed language.
You must call it from managed or mixed code (or call it from COM)

Solution 1, suggested by Cdrake.
1. Convert your C++ app to C++/CLI (/clr switch)

Another option is:
2. Create an interop assembly/DLL in C++/CLI which you use as a normal DLL from your C++
Argonia 14-Sep-12 9:09am
Now i just have to find suitable types in c++ which can hold values from the types in f# :'(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 12 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100