C++ / CLI in action

Free Download

Authors:

Series: Manning

ISBN: 9781932394818, 1-932394-81-8

Size: 19 MB (20378461 bytes)

Pages: 416/416

File format:

Language:

Publishing Year:

Category: Tags: , ,

Nishant Sivakumar9781932394818, 1-932394-81-8

C++ is the language of choice for thousands of applications and millions of lines of code. With C++/CLI, developers can integrate existing C++ code into the .NET platform without rewriting their applications. This book explores the C++/CLI syntax, teaches how to mix native C++ and managed .NET code, and shows how to integrate C++ with Windows Forms, WPF (Avalon), and WCF (Indigo).Imagine taking a C++-based program you’ve been using for a decade and giving it a snazzy new interface using Windows Presentation Foundation. How about making your old business applications talk to your new ones using Windows Communication Foundation. C++/CLI makes this – and more – possible. C++/CLI in Action shows you how to bridge the gap between your existing C++ code and the .NET platform.

Table of contents :
C++/CLI in Action……Page 1
brief contents……Page 8
contents……Page 10
preface……Page 16
acknowledgments……Page 18
about this book……Page 20
Roadmap……Page 21
Author Online……Page 22
About the title……Page 23
About the cover illustration……Page 24
Part 1 – The C++/CLI Language……Page 26
Introduction to C++/CLI……Page 28
1.1 The role of C++/CLI……Page 29
1.1.1 What C++/CLI can do for you……Page 31
1.1.2 The rationale behind the new syntax……Page 33
1.2 Hello World in C++/CLI……Page 38
1.2.1 The /clr compiler option……Page 40
1.2.2 Using VC++ 2005 to create a /clr application……Page 41
1.3 Declaring CLR types……Page 43
1.3.1 Class modifiers……Page 45
1.3.2 CLI types and inheritance……Page 47
1.4.1 Syntax for using handles……Page 49
1.4.2 Tracking references……Page 51
1.5.1 The gcnew operator……Page 53
1.5.2 Constructors……Page 56
1.5.3 Copy constructors……Page 58
1.5.4 Assignment operators……Page 61
1.6.1 Implicit boxing in the new syntax……Page 63
1.6.2 Boxing and type-safety……Page 65
1.6.3 Implementation at the MSIL level……Page 66
1.6.4 Assigning null to a boxed value type……Page 68
1.7 Summary……Page 70
Getting into the CLI: properties, delegates and arrays……Page 71
2.1 Properties……Page 72
2.1.1 Scalar Properties……Page 73
2.1.2 Indexed properties……Page 80
2.2 Delegates and events……Page 83
2.2.1 Delegates……Page 84
2.2.2 Events……Page 89
2.3 CLI Arrays……Page 93
2.3.1 Basic CLI array concepts……Page 94
2.3.2 Single-dimensional arrays……Page 95
2.3.3 Multidimensional arrays……Page 96
2.3.4 Jagged arrays……Page 97
2.3.5 Arrays as function arguments……Page 99
2.3.6 Returning arrays from functions……Page 100
2.3.7 Parameter arrays……Page 101
2.3.8 Using System::Array methods……Page 102
2.3.9 Array covariance……Page 105
2.3.10 Arrays of non-CLI objects……Page 106
2.3.11 Directly accessing CLI arrays using native pointers……Page 108
2.4 Summary……Page 109
More C++/CLI: stack semantics, function overriding, and generic programming……Page 111
3.1 Stack semantics and deterministic destruction……Page 112
3.1.1 The new destructor and finalizer syntaxes……Page 113
3.1.2 Stack semantics……Page 121
3.1.3 Guidelines for using destructors and stack semantics……Page 126
3.2 Function overriding……Page 127
3.2.1 Explicit overriding……Page 128
3.2.2 Renamed overriding……Page 129
3.2.3 Multiple overriding……Page 130
3.2.4 Sealed and abstract functions……Page 131
3.3.1 Why have parameterized types?……Page 133
3.3.2 Generics syntax for classes and functions……Page 135
3.3.3 Constraint mechanism……Page 138
3.3.4 Issues with the constraint mechanism and simple types……Page 141
3.3.5 Comparison with templates……Page 145
3.3.6 Managed templates……Page 149
3.4 Summary……Page 154
Part 2 – Mixing managed and native code……Page 156
Introduction to mixed-mode programming……Page 158
4.1 Using interior and pinning pointers……Page 160
4.1.1 Interior pointers……Page 161
4.1.2 Pinning pointers……Page 166
4.2 Working with interop mechanisms……Page 172
4.2.1 Accessing a managed library from native code……Page 173
4.2.2 Accessing a native library from managed code……Page 181
4.3.1 Native types with managed members……Page 187
4.3.2 Managed types with native members……Page 191
4.4.1 Using GetFunctionPointerForDelegate……Page 198
4.4.2 Using GetDelegateForFunctionPointer……Page 200
4.5 Summary……Page 202
Interoping with native libraries from managed applications……Page 204
5.1.1 Marshalling native strings……Page 206
5.1.2 Marshalling arrays……Page 209
5.1.3 Simulating a native static array with managed code……Page 210
5.2 Double thunking in mixed-mode function calls……Page 211
5.3 Wrapping a native API and exposing a CLI interface……Page 215
5.3.1 Overview of the native API……Page 216
5.3.2 Writing the CLI wrapper……Page 218
5.4 Exposing an MFC extension DLL to .NET……Page 231
5.4.1 Overview of the MFC extension DLL……Page 232
5.4.2 Writing the managed regular MFC DLL wrapper……Page 233
5.5.1 The COM object to interop with……Page 237
5.5.2 Writing the custom RCW……Page 240
5.6 Writing a single mixed-mode DLL for both managed and native clients……Page 243
5.6.1 Wrapping the System::Object class……Page 245
5.6.2 Writing derived class wrappers……Page 248
5.7 Summary……Page 252
Part 3 – Using managed frameworks from native applications……Page 254
Interoping Windows Forms with MFC……Page 256
6.1 A simple Windows Forms application……Page 258
6.2 Hosting a Windows Forms control in an MFC dialog……Page 260
6.3 Hosting a Windows Forms control as an MFC view……Page 264
6.4 Giving your MFC apps an Office 2003 style UI……Page 274
6.5 Using a Windows Forms control as an MFC dialog……Page 286
6.6 Using an MFC control in a Windows Forms form……Page 292
6.6.1 The custom MFC control……Page 293
6.6.2 Hosting the MFC control from WinForms……Page 296
6.6.3 Using the wrapped control from a WinForms app……Page 298
6.7 Summary……Page 299
Using C++/CLI to target Windows Presentation Foundation applications……Page 301
7.1 What is WPF?……Page 303
7.1.1 Overview of XAML……Page 305
7.1.2 Anatomy of a simple WPF application……Page 308
7.2 Using C++/CLI to write a WPF application……Page 313
7.2.2 Using procedural code……Page 314
7.2.3 Dynamically loading XAML……Page 319
7.2.4 Deriving from a class in a C# DLL……Page 322
7.3.1 Using brushes and shapes……Page 325
7.3.2 Transformations……Page 329
7.4.1 Using a mixed-mode extension DLL……Page 335
7.4.2 Using a mixed-mode application……Page 344
7.5 Hosting a native control in a WPF application……Page 351
7.6 Summary……Page 356
Accessing the Windows Communication Foundation with C++/CLI……Page 357
8.1 Hello World with the Windows Communication Foundation……Page 359
8.2 Duplex communication in WCF……Page 363
8.2.1 Creating the service……Page 365
8.2.2 Creating the client……Page 367
8.3 Migrating a native DCOM application to WCF……Page 369
8.3.1 The example DCOM server……Page 371
8.3.2 The native MFC client……Page 373
8.3.3 Writing a WCF proxy service……Page 376
8.3.4 Modifying the MFC client to use WCF……Page 381
8.3.5 Writing a pure WCF service……Page 384
8.4 Hosting a WCF service in an IIS server……Page 387
8.5 Summary……Page 391
Appendix: A concise introduction to the .NET Framework……Page 393
What is the .NET Framework?……Page 394
The Common Language Runtime……Page 396
Executing a .NET program……Page 399
Visual C++ and .NET……Page 400
The Base Class Library……Page 402
CLI types……Page 405
Memory management……Page 406
Application domains……Page 407
Reflection……Page 408
B……Page 410
D……Page 411
G……Page 412
M……Page 413
R……Page 414
V……Page 415
X……Page 416

Reviews

There are no reviews yet.

Be the first to review “C++ / CLI in action”
Shopping Cart
Scroll to Top