Book description
C++/CLI in Action is a practical guide that will help you breathe new life into your legacy C++ programs. The book begins with a concise C++/CLI tutorial. It then quickly moves to the key themes of native/managed code interop and mixed-mode programming. You'll learn to take advantage of GUI frameworks like Windows Forms and WPF while keeping your native C++ business logic. The book also covers methods for accessing C# or VB.NET components and libraries.
About the Technology
Developers initially welcomed Microsoft's Managed C++ for .NET, but the twisted syntax made it difficult to use. Its much-improved replacement, C++/CLI, now provides an effective bridge between the native and managed programming worlds. Using this technology, developers can combine existing C++ programs and .NET applications with little or no refactoring. Accessing .NET libraries like Windows Forms, WPF, and WCF from standard C++ is equally easy.
About the Book
What's Inside
- Call C++ libraries from C# or VB.NET
- C++ for WPF and WCF
- Mixed-mode programming techniques
- Move from Managed C++ to C++/CLI
About the Reader
Written for readers with a working knowledge of C++.
About the Author
Nishant Sivakumar has extensive experience with Visual C++, MFC, C#, and the .NET Framework. He has been a Microsoft Visual C++ MVP since 2002 and maintains an MVP tips and tricks website and a popular blog. Nish is in charge of several products for The Code Project. He also authored Extending MFC Applications with the .NET Framework. Nish lives with his wife in Toronto, Ontario.
Quotes
“... a great resource, an outstanding job, a must-read...”
- Ayman B. Shoukry, VC++ Team, Microsoft Corporation
“... explains the C++/CLI language and shows how it can be used.”
- James Johnson
“... a great reference ... a must-have in any C++ programmer’s bookshelf.”
- Michael L. Taylor, C# MVP
“... absolutely the only book you’ll need to learn this powerful new .NET language ... a lifesaver... .”
- Christian Graus, Code Project
Table of contents
- preface
- acknowledgments
- about this book
-
Part 1 - The C++/CLI Language
-
Introduction to C++/CLI
- 1.1 The role of C++/CLI (1/2)
- 1.1 The role of C++/CLI (2/2)
- 1.2 Hello World in C++/CLI
- 1.3 Declaring CLR types (1/2)
- 1.3 Declaring CLR types (2/2)
- 1.4 Handles: the CLI equivalent to pointers
- 1.5 Instantiating CLI classes (1/2)
- 1.5 Instantiating CLI classes (2/2)
- 1.6 Boxing and unboxing (1/2)
- 1.6 Boxing and unboxing (2/2)
- 1.7 Summary
-
Getting into the CLI: properties, delegates and arrays
- 2.1 Properties (1/3)
- 2.1 Properties (2/3)
- 2.1 Properties (3/3)
- 2.2 Delegates and events (1/2)
- 2.2 Delegates and events (2/2)
- 2.3 CLI Arrays (1/4)
- 2.3 CLI Arrays (2/4)
- 2.3 CLI Arrays (3/4)
-
2.3 CLI Arrays (4/4)
- 2.3.1 Basic CLI array concepts
- 2.3.2 Single-dimensional arrays
- 2.3.3 Multidimensional arrays
- 2.3.4 Jagged arrays
- 2.3.5 Arrays as function arguments
- 2.3.6 Returning arrays from functions
- 2.3.7 Parameter arrays
- 2.3.8 Using System::Array methods
- 2.3.9 Array covariance
- 2.3.10 Arrays of non-CLI objects
- 2.3.11 Directly accessing CLI arrays using native pointers
- 2.4 Summary
-
More C++/CLI: stack semantics, function overriding, and generic programming
- 3.1 Stack semantics and deterministic destruction (1/3)
- 3.1 Stack semantics and deterministic destruction (2/3)
- 3.1 Stack semantics and deterministic destruction (3/3)
- 3.2 Function overriding (1/2)
- 3.2 Function overriding (2/2)
- 3.3 Generics and managed templates (1/5)
- 3.3 Generics and managed templates (2/5)
- 3.3 Generics and managed templates (3/5)
- 3.3 Generics and managed templates (4/5)
- 3.3 Generics and managed templates (5/5)
- 3.4 Summary
-
Introduction to C++/CLI
-
Part 2 - Mixing managed and native code
-
Introduction to mixed-mode programming
- 4.1 Using interior and pinning pointers (1/3)
- 4.1 Using interior and pinning pointers (2/3)
- 4.1 Using interior and pinning pointers (3/3)
- 4.2 Working with interop mechanisms (1/3)
- 4.2 Working with interop mechanisms (2/3)
- 4.2 Working with interop mechanisms (3/3)
- 4.3 Using mixed types (1/3)
- 4.3 Using mixed types (2/3)
- 4.3 Using mixed types (3/3)
- 4.4 Function pointers and delegates: bridging the gap
- 4.5 Summary
-
Interoping with native libraries from managed applications
- 5.1 Converting between managed and native types
- 5.2 Double thunking in mixed-mode function calls
- 5.3 Wrapping a native API and exposing a CLI interface (1/4)
- 5.3 Wrapping a native API and exposing a CLI interface (2/4)
- 5.3 Wrapping a native API and exposing a CLI interface (3/4)
- 5.3 Wrapping a native API and exposing a CLI interface (4/4)
- 5.4 Exposing an MFC extension DLL to .NET (1/2)
- 5.4 Exposing an MFC extension DLL to .NET (2/2)
- 5.5 Accessing a COM object via a custom RCW (1/2)
- 5.5 Accessing a COM object via a custom RCW (2/2)
- 5.6 Writing a single mixed-mode DLL for both managed and native clients (1/2)
- 5.6 Writing a single mixed-mode DLL for both managed and native clients (2/2)
- 5.7 Summary
-
Introduction to mixed-mode programming
-
Part 3 - Using managed frameworks from native applications
-
Interoping Windows Forms with MFC
- 6.1 A simple Windows Forms application
- 6.2 Hosting a Windows Forms control in an MFC dialog
- 6.3 Hosting a Windows Forms control as an MFC view (1/2)
- 6.3 Hosting a Windows Forms control as an MFC view (2/2)
- 6.4 Giving your MFC apps an Office 2003 style UI (1/3)
- 6.4 Giving your MFC apps an Office 2003 style UI (2/3)
- 6.4 Giving your MFC apps an Office 2003 style UI (3/3)
- 6.5 Using a Windows Forms control as an MFC dialog (1/2)
- 6.5 Using a Windows Forms control as an MFC dialog (2/2)
- 6.6 Using an MFC control in a Windows Forms form (1/2)
- 6.6 Using an MFC control in a Windows Forms form (2/2)
- 6.7 Summary
-
Using C++/CLI to target Windows Presentation Foundation applications
- 7.1 What is WPF? (1/2)
- 7.1 What is WPF? (2/2)
- 7.2 Using C++/CLI to write a WPF application (1/3)
- 7.2 Using C++/CLI to write a WPF application (2/3)
- 7.2 Using C++/CLI to write a WPF application (3/3)
- 7.3 A brief look at some WPF Graphics features (1/2)
- 7.3 A brief look at some WPF Graphics features (2/2)
- 7.4 Hosting a WPF control in a native C++ application (1/4)
- 7.4 Hosting a WPF control in a native C++ application (2/4)
- 7.4 Hosting a WPF control in a native C++ application (3/4)
- 7.4 Hosting a WPF control in a native C++ application (4/4)
- 7.5 Hosting a native control in a WPF application
- 7.6 Summary
-
Accessing the Windows Communication Foundation with C++/CLI
- 8.1 Hello World with the Windows Communication Foundation
- 8.2 Duplex communication in WCF (1/2)
- 8.2 Duplex communication in WCF (2/2)
- 8.3 Migrating a native DCOM application to WCF (1/4)
- 8.3 Migrating a native DCOM application to WCF (2/4)
- 8.3 Migrating a native DCOM application to WCF (3/4)
- 8.3 Migrating a native DCOM application to WCF (4/4)
- 8.4 Hosting a WCF service in an IIS server
- 8.5 Summary
- Appendix: A concise introduction to the .NET Framework
-
Interoping Windows Forms with MFC
- index
Product information
- Title: C++/CLI in Action
- Author(s):
- Release date: April 2007
- Publisher(s): Manning Publications
- ISBN: 9781932394818
You might also like
book
Windows Runtime via C#
Delve inside the Windows Runtime - and learn best ways to design and build Windows Store …
book
C++20 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library
This quick C++ 20 guide is a condensed code and syntax reference to the popular programming …
book
.NET IL Assembler
" Advanced .NET IL Assembler is a comprehensive drill-down into the inner workings of the .NET …
book
Foundations of C++/CLI: The Visual C++ Language for .NET 3.5
Foundations of C++/CLI: The Visual C++ Language for .NET 3.5 introduces C++/CLI, Microsoft's extensions to the …