1. Home
  2. Computing & Technology
  3. C / C++ / C#

Review of Pro Visual C++/CLI and the .NET 2.0 Platform
Moving C++ Applications into .NET 2.0

About.com Rating 4.5

By David Bolton, About.com

Book Cover for Pro Visual C++/CLI
C++ is an established and rich programming language that is well understood, at least by compiler writers and advanced developers. But rewriting C++ applications to be managed code under .NET 2.0 C++/CLI is a lot more complicated than first appears. This book explains what is needed to do the rewrite (or write managed C++) and the pitfalls to avoid.

About C++/CLI on .NET 2.0

Getting C++ to work under .NET was no easy task. The first time this was attempted with .NET 1.0 was called Managed Extensions but that didn't set the world on fire. Under .NET 2.0 it's now completely different and is called C++/CLI. The designers have learnt a few lessons from the first attempt.

If you have a large chunk of C++ code that runs on Win 32 and you wish to run it under .NET there are several options. You could link to it as unmanaged code, or you could rewrite it in C# or other native .NET languages or you could rewrite it in C++/CLI to take advantage of managed code. If you choose the latter option, you need a pretty technical overview of C++/CLI and that is what this book provides. It's one of only three or four books that deals with this subject.

Why is there such a problem with C++ on .NET?

In a nutshell, pointers. .NET's code is managed by the .NET Framework. This means no pointers, and no possibility of memory being overwritten accidentally. Fitting C++ into the .NET managed code world requires it to work within the framework's memory management, code security and garbage collection. These are all features that prior to .NET, were coded by the developer, if at all.

Fraser introduces all this with a "view from 30,000 feet"; a very comprehensive overview that is certainly needed to introduce a fairly complex area of development. He also points out that C++/CLI cannot be used for .NET web application development anymore (though web services are allowed).

Writing Managed C++ Code

In chapter two the differences are highlighted in more detail- for example CLI enums and C++ enums are not the same. It becomes apparent very quickly that if you want to write safe managed code in C++, you need to think a lot more about your code. On the plus side you get new statements like for each.

The book moves quickly on into advanced territory. It's a mixture of explaining standard C++ features and how to work with .NET. Beginners to programming would probably feel quite a way out of their depth, this is certainly not a beginners book- it is for professionals as reflected by the title. C++ has its complicated bits and C++/CLI is even worse. Not only do you have templates but you also have generics which are subtly different. The book is bulked up by the sheer quantity of example code but without it, the subject would have been very heavy going. 850 Pages makes for a lot of reading!

To Finish Off

The rest of this section covers XML, ADO for connecting to databases, web services, multi threading, network programming, assembly programming and security in 300 pages.

Finally the last two chapters looks at unsafe C++ which includes pointers and calling COM servers.

Conclusion

If your C++ ability is past the beginner stage and you have to move code onto .NET then this book is highly recommended. It will repay its cost within hours through saving you wasted time. C++ developers will find that C++/CLI has some very odd looking syntax and the welcome examples provide a way to quickly acquire familiarity.
User Reviews Write Review
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Book Reviews
  5. Review of Pro Visual C++/CLI and the .NET 2.0 Platform>

©2009 About.com, a part of The New York Times Company.

All rights reserved.