Take the 2-minute tour ×

I wrote a managed C++ application a few years ago. It was just a personal project and I chose managed c++ just because I found it interesting. I remember it felt like it just took a lot more time than doing c# and there wasn't anything to gain from it in my case at least.

When is C++/CLI a good choice in reality? What is it's benefits?

share|improve this question
Also, this is a duplicate of stackoverflow.com/questions/1933210/c-cli-why-should-i-use-it, which gave a better answer than I did –  Patrick Lafferty Oct 4 '11 at 18:17
This is a closer dupe: stackoverflow.com/questions/1874783/… –  Ben Voigt Oct 5 '11 at 14:23
add comment

2 Answers

up vote 3 down vote accepted

The only reason for using C++/CLI is so you can use a native library in a managed application. Even Microsoft says it shouldn't be used on its own:

The second major consideration for using C++/CLI is to remember that this is only intended to be a bridge between the managed and native worlds and not intended to be a technology you use to write the bulk of your application. It is certainly possible to do so, but you'll find that developer productivity is much lower than in a pure C++ or pure C#/Visual Basic environment and that your application runs much slower to boot. So when you use C++/CLI, compile only the files you need with the /clr switch, and use a combination of pure managed or pure native assemblies to build the core functionality of your application.


share|improve this answer
That sounds very reasonable. Thank you! :) –  Carl R Oct 4 '11 at 18:11
add comment

For me, it's far less difficult to write managed code in C#, but sometimes the performance that C++ offers makes it a better choice. I write the performance-critical code in c++, and the rest in C#. The only reason for C++/CLI is so that the native code and managed code can be used together.

Herb Sutter's design rational:

C++/CLI’s mission is to provide direct access for C++ programmers to use existing CLI libraries and create new ones, with little or no performance overhead, with the minimum amount of extra notation, and with full ISO C++ compatibility.


share|improve this answer
add comment

Your Answer


