C++/CLI in Action NISHANT SIVAKUMAR MANNING. Greenwich (74 w. long.)

Similar documents
Introduction to C++/CLI 3. What C++/CLI can do for you 6 The rationale behind the new syntax Hello World in C++/CLI 13

Expert C++/CLI:.NET for Visual C++ Programmers

Microsoft Visual C# Step by Step. John Sharp

C# Programming: From Problem Analysis to Program Design. Fourth Edition

CHAPTER 1: INTRODUCING C# 3

C++/CLI in Action NISHANT SIVAKUMAR MANNING. Greenwich (74 w. long.)

Microsoft. Microsoft Visual C# Step by Step. John Sharp

C# Programming in the.net Framework

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Migrate Your Skills to Microsoft.NET Framework 2.0 and 3.0 using Visual Studio 2005 (C#)

Table of Contents Preface Bare Necessities... 17

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio

Programming C# 5.0. Ian Griffiths O'REILLY' Beijing Cambridge * Farnham Kbln Sebastopol Tokyo

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

ALPHAPRIMETECH 112 New South Road, Hicksville, NY 11801

.Net. Course Content ASP.NET

S A M P L E C H A P T E R

C++ (Non for C Programmer) (BT307) 40 Hours

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Object-Oriented Programming in C# (VS 2015)

Jim Jackson II Ian Gilman

C++/CLI In Action By Nishant Sivakumar

02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211

Apex TG India Pvt. Ltd.

CLI and CLR. Antonio Cisternino Giuseppe Attardi

DOT NET Syllabus (6 Months)

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

Object-Oriented Programming in C# (VS 2012)

Department of Computer Applications

The C# Programming Language. Overview

Windows Presentation Foundation Programming Using C#

Top 40.NET Interview Questions & Answers

DOT NET SYLLABUS FOR 6 MONTHS

C# in Depth SECOND EDITION JON SKEET. MANNING Greenwich (74 w. long.)

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Course Hours

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

Dot Net Online Training

J, K. Hello World HelloCpp.cpp, 4 retrieve source files, 4 Visual C++ IDE (see Visual C++ IDE) Visual Studio Tools folder, 4

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

C# in Depth THIRD EDITION

Chapter 1 Getting Started with Windows Presentation Foundation

S A M P L E C H A P T E R

Diploma in Microsoft.NET

S.Sakthi Vinayagam Sr. AP/CSE, C.Arun AP/IT

Windows 8. Rainer Stropek. System Architecture. System Architecture re of Windows Store Apps. Saves the day. software architects gmbh

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

Microsoft Visual Studio 2010

UNIT 1 PART A PART B

Introduce C# as Object Oriented programming language. Explain, tokens,


C# Syllabus. MS.NET Framework Introduction

Override Control Using Contextual Keywords

Developing Windows Applications with Microsoft Visual Studio 2010

University of West Bohemia in Pilsen. Faculty of Applied Sciences. Department of Computer Science and Engineering DIPLOMA THESIS

CHAPTER 1: INTRODUCTION TO THE IDE 3


"Charting the Course... MOC A Developing Data Access Solutions with Microsoft Visual Studio Course Summary

C++ Coding Standards. 101 Rules, Guidelines, and Best Practices. Herb Sutter Andrei Alexandrescu. Boston. 'Y.'YAddison-Wesley

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Visual C# 2008 How to Program, 3/E Outline

DE Developing Windows Applications with Microsoft Visual Studio 2010

Programming. Principles and Practice Using C++ Bjarne Stroustrup. / Addison-Wesley. Second Edition

C# 6.0 in a nutshell / Joseph Albahari & Ben Albahari. 6th ed. Beijin [etc.], cop Spis treści

HCIM SUMMER WORKSHOP Introduction to C#

Introduction to Programming Using Java (98-388)

Introduction to Programming Microsoft.NET Framework Applications with Microsoft Visual Studio 2005 (C#)

DEVELOPING WINDOWS APPLICATIONS WITH MICROSOFT VISUAL STUDIO 2010

Pro XAML with C# From Design to Deployment on WPF, Windows Store, and Windows Phone. Buddy James. Lori Lalonde

.NET FRAMEWORK. Visual C#.Net

Object-Oriented Programming

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Whom Is This Book For?... xxiv How Is This Book Organized?... xxiv Additional Resources... xxvi

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

B.E /B.TECH DEGREE EXAMINATIONS,

Team Developer and.net

Effective Unit Testing

Introduction to Microsoft.NET Programming Using Microsoft Visual Studio 2008 (C#) Course Overview. Prerequisites. Audience.

C#.NET TRAINING / /

Module 1. An Introduction to C# Module 2. Classes and Objects. Vasundhara Sector 14-A, Plot No , Near Vaishali Metro Station,Ghaziabad

Absolute C++ Walter Savitch

Advanced C++ Topics. Alexander Warg, 2017

Standard. Number of Correlations

brief contents PART 1 INTRODUCING WINDOWS PHONE... 1 PART 2 CORE WINDOWS PHONE... 57

jquery in Action Second Edition !II BEAR BIBEAULT YEHUDA KATZ MANNING Greenwich (74 0 w. lang.)

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

Prerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C#

C++11: 10 Features You Should be Using. Gordon R&D Runtime Engineer Codeplay Software Ltd.

C # Language Specification

Developing Windows Applications with Microsoft Visual Studio 2010

TABLE OF CONTENTS PREFACE CHAPTER1 INTRODUCING WINDOWS++ 1

Introduction to Microsoft.NET Framework Programming using VS 2005 (C#)

Developing Data Access Solutions with Microsoft Visual Studio 2010

DOT NET COURSE BROCHURE

Syllabus- Java + Android. Java Fundamentals

Dot Net Framework 4.0: Advanced Microsoft C#.NET Web Development

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

Visual C++ MFC Programming By Example By John E. Swanke

Transcription:

C++/CLI in Action NISHANT SIVAKUMAR 11 MANNING Greenwich (74 w. long.)

brief contents PART 1 THE C++/CLI LANGUAGE 1 1 IntroductiontoC++/CLI 3 2 Getting into the CLI: properties, delegates and arrays 46 3 More C++/CLI: Stack semantics, function overriding, and generic programming 86 PART 2 MIXING MANAGED AND NATIVE CODE 131 4 Introduction to mixed-mode programming 133 5 Interoping with native libraries from managed applications 179 PART 3 USING MANAGED FRAMEWORKS FROM NATIVE APPLICATIONS 229 6 Interoping Windows Forms with MFC 231 7 Using C++/CLI to target Windows Presentation Foundation applications 276 8 Accessing the Windows Communication Foundation withc++/cli 332 vü

preface xv acknowledgments xvii about this book xix contents PART 1 THE C++/CLI LANGUAGE 1 Introduction to C+ +/CLI 3 1.1 The role of C++/CLI 4 What C+ +/CLI can doforyou the new syntax 8 1.2 Hello World in C++/CLI 13 6 The rationale behind The Iclr Compiler Option 15 * Using VC+ + 2005 to create a Iclr application 16 1.3 Declaring CLR types 18 Class modifiers 20 CLI types and inheritance 22 1.4 Handies: the CLI equivalent to pointers 24 Syntax for using handles 24 Tracking references 26 1.5 Instantiating CLI classes 28 The gcnew Operator 28 Constructors 31 Copy constructors 33 Assignment Operators 36 IX

1.6 Boxing and unboxing 38 Implicit boxing in the new syntax 38 Boxing and type-safety 40 Implementation at the MSIL level 41 Assigning null to a boxed value type 43 1.7 Summary 45 Getting into the CLI: properties, delegates and arrays 2.1 Properties 47 Scalar Properties 48 Indexed properties 55 2.2 Delegates and events 58 Delegates 59 Events 64 2.3 CLI Arrays 68 Basic CLI array concepts 69 * Single-dimensional arrays 70 Multidimensional arrays 71 Jagged arrays 72 Arrays as function arguments 74 * Returning arrays fromfunctions 75 Parameter arrays 76 Using System::Array methods 77 * Array covariance 80 Arrays ofnon-cli objects 81 Directly accessing CLI arrays using native pointers 83 2.4 Summary 84 More C++/CLI: Stack semantics, function overriding, and generic programming 86 3.1 Stack semantics and deterministic destruction 87 The new destructor andfinalizer syntaxes 88 Stack semantics 96 Guidelines for using destructors and stock semantics 101 3.2 Function overriding 102 Explicit overriding 103 Renamed overriding 104 Multiple overriding 105 Sealed and abstract functions 106 3.3 Generics and managed templates 108 Whyhaveparameterizedtypes? 108 Generics syntax for classes and functions 110 Constraint mechanism 113 Issues with the constraint mechanism and simple types 116 Comparison with templates 120 * Managed templates 124 3.4 Summary 129

CONTENTS xi PART 2 MIXING MANAGED AND NATIVE CODE 131 Introduction to mixed-mode programming 133 4.1 Using interior and pinning pointers 135 Interior pointers 136 * Pinning pointers 141 4.2 Working with interop mechanisms 147 Accessing a managed libraryfrom native code 148 Accessing a native libraryfrom managed code 156 4.3 Using mixed types 162 Nativetypeswith managed members 162 Managedtypeswith native members 166 4.4 Function pointers and delegates: bridging thegap 173 Using GetFunctionPointerForDelegate 173 Using GetDelegateForFunctionPointer 175 4.5 Summary 177 Interoping with native libraries from managed applications 179 5.1 Converting between managed and native types 181 Marshalling native strings 181 Marshalling arrays 184 Simulating a native static array with managed code 185 5.2 Double thunking in mixed-mode function calls 186 5.3 Wrapping a native API and exposing a CLI interface 190 Overview ofthe native API 191 Writing the CLI wrapper 193 ba Exposing an MFC extension DLL to.net 206 Overview ofthe MFC extension DLL 207 Writing the managed regulär MFC DLL wrapper 208 5.5 Accessing a COM object via a custom RCW 212 The COM object to interop with 212 * Writing the custom RCW 215 Using the custom RCW 218

CONTENTS 5.6 Writing a single mixed-mode DLL for both managed and native clients 218 Wrapping the System::Object class 220 Writing derived class wrappers 223 5.7 Summary 227 PART 3 USING MANAGED FRAMEWORKS FROM NATIVE APPLICATIONS 229 /C Interoping Windows Forms with MFC 231 6.1 A simple Windows Forms application 233 6.2 Hosting a Windows Forms control in an MFC dialog 235 6.3 Hosting a Windows Forms control as an MFC view 239 6.4 Giving your MFC apps an Office 2003 style UI 249 6.5 Using a Windows Forms control as an MFC dialog 261 6.6 Using an MFC control in a Windows Forms form 267 The custom MFC control 268 Hosting the MFC control from WinForms 271 Using the wrapped control from a WinForms app 273 6.7 Summary 274 *1 Using C+ +/CLI to target Windows Presentation Foundation applications 276 7.1 WhatisWPF? 278 Overview ofxaml 280 * Anatomy ofa simple WPF application 283 7.2 Using C++/CLI to write a WPF application 288 Creating a new C+ +/CU Avalon project 289 Using procedural code 289 Dynamically loading XAML 294 ' Derivingfrom a class-in a C# DLL 297 7.3 A brief look at some WPF Graphics features 300 Using brushes and shapes 300 * Transformations 304

CONTENTS 7.4 Hosting a WPF control in a native C++ application 310 Using a mixed-mode extension DLL 310 Using a mixed-mode application 319 7.5 Hosting a native control in a WPF application 326 8 7.6 Summary 331 Accessing the Windows Communication Foundation withc++/cli 332 8.1 Hello World with the Windows Communication Foundation 334 8.2 Duplex communication in WCF 338 Creating the Service 340 Creating the dient 342 8.3 Migrating a native DCOM application to WCF 344 The example DCOM Server 346 The native MFC dient 348 Writing a WCFproxy Service 351 Modifying the MFC dient tousewcf 356 Writing a pure WCF Service 359 Comparison ofthe two migration methods 362 8.4 Hosting a WCF service in an IIS server 362 8.5 Summary 366 Appendix A concise introduction to the.net Framework 368 index 385