You are previewing Microsoft® Visual C++® .NET 2003 Kick Start.
O'Reilly logo
Microsoft® Visual C++® .NET 2003 Kick Start

Book Description

Microsoft Visual C++ .NET 2003 Kick Start is targeted toward developers interested in making the jump to .NET, working programmers already familiar with another programming language or the previous version of VS. Visual C++ .NET 2003 Kick Start speeds through basic concepts and focuses on practical examples and benefits of moving to VC++ .NET. This book explains how VC++ code interacts with the .NET Framework, the extra capabilities of VC++ compared to VB.NET and C# in .NET code interoperability, how to use Windows Forms (a new feature for VC++ .NET in the 2003 edition), and how to migrate from Visual Studio 6 and COM. The author covers the use of managed and unmanaged Visual C++ code, using both types for most examples. Full of code examples, tips, and professional insights, this book provides maximum learning with minimum investment of time and effort.

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. Who Should Read This Book
    2. How This Book Is Organized
      1. Chapter 1: C++, Visual C++, and Managed C++: What's the Difference?
      2. Chapter 2: Creating Test Harnesses and Starter Applications
      3. Chapter 3: The .NET Base Class Libraries
      4. Chapter 4: Building Simple User Interfaces with Windows Forms
      5. Chapter 5: Writing a Class Library in Unmanaged C++
      6. Chapter 6: Writing a Class Library in Managed C++
      7. Chapter 7: Building DLLs in Unmanaged C++
      8. Chapter 8: Writing COM Components in C++
      9. Chapter 9: Using Existing COM Components in C++
      10. Chapter 10: Writing and Consuming a Web Service
      11. Chapter 11: Writing a Data Layer in Managed C++
      12. Chapter 12: Writing a Windows Service
      13. Chapter 13: Strengthening Your Managed Applications with Security and Encryption
      14. Chapter 14: Moving Layers to Different Machines with .NET Remoting
      15. Chapter 15: Building Advanced User Interfaces in Managed C++
    3. Conventions Used in This Book
    4. Source Code for This Book
  6. 1. C++, Visual C++, and Managed C++: What's the Difference?
    1. Differences Between Visual C++ and C++
      1. The Visual C++ Suite of Tools
      2. The Managed Extensions to C++
      3. Applications That Run Directly Under Windows
    2. Managed and Unmanaged Code
      1. Advantages of Managed Code
      2. Advantages of Unmanaged Code
      3. Performance Considerations
    3. Managed and Unmanaged Data
      1. Unmanaged Data
      2. Garbage-Collected Classes
        1. Inheritance Restrictions
        2. Single Inheritance
        3. Additional Restrictions on Garbage-Collected Classes
      3. Value Classes
      4. Pinning and Boxing
        1. Boxing a Fundamental Type
        2. Pinning a Pointer
    4. Properties
    5. In Brief
  7. 2. Creating Test Harnesses and Starter Applications
    1. Application Types You Can Create with Visual C++
    2. What Is a Test Harness?
    3. Creating an Unmanaged C++ Application
    4. Testing an Unmanaged Class with an Unmanaged Test Harness
      1. Writing a Simple Class
      2. Writing a Test Harness
      3. Debugging an Unmanaged Console Application
    5. Creating a Managed C++ Application
    6. Testing a Managed Class with a Managed Test Harness
    7. In Brief
  8. 3. The .NET Base Class Libraries
    1. Libraries Shared Across Languages
    2. Namespaces in C++
    3. The System Namespace
      1. The System::Console Class
      2. The System::String and System::Stringbuilder Classes
      3. The System::DateTime Structure
    4. Other Useful Namespaces
      1. The System::IO Namespace
      2. The System::Text Namespace
        1. Regular Expression Syntax
      3. The System::Collections Namespace
      4. The System::Threading Namespace
    5. In Brief
  9. 4. Building Simple User Interfaces with Windows Forms
    1. A Managed C++ Windows Forms Application
    2. Using the Toolbox to Build the User Interface
      1. Controls in the Toolbox
      2. The Layout Toolbar
    3. Anchoring, Docking, and Other Properties of Controls
      1. The Anchor Property
      2. The Dock Property
    4. Writing Event Handlers
      1. Adding an Event Handler
      2. Writing an Event Handler
    5. Using a DataGrid, DataView, and DataFilter
      1. Creating XML, Schemas, and Typed Datasets
      2. Connecting a DataGrid to a DataSet
      3. Working with a Data View
    6. Creating a Multiple-Form Interface
      1. Writing a Form Class
      2. Properties of Text Boxes
      3. Displaying a Form
        1. Displaying a Modal Form
        2. Retrieving Information from a Form
        3. Passing Information to a Form
        4. Displaying a Modeless Form
    7. In Brief
  10. 5. Writing a Class Library in Unmanaged C++
    1. The Role of a Class Library in a Layered Application
    2. Creating a Class Library
    3. Calling the Library from Other Applications
      1. Creating a Release Version of the Library
      2. Calling the Library from an Unmanaged C++ Application
      3. Calling the Library from a Managed C++ Application
      4. Calling the Library from Other Managed Languages
    4. Advantages and Disadvantages of Writing an Unmanaged Class Library
    5. In Brief
  11. 6. Writing a Class Library in Managed C++
    1. Advantages and Disadvantages of a Managed Class Library
    2. Building a Managed Class Library
    3. Using the Class Library from Managed Code
      1. Using the Library from Code in the Same Solution
      2. Creating a Release Version of the Library
      3. Using the Library from Code in a Different Solution
    4. Calling the Library from Another Managed Language
    5. Managed and Unmanaged Data in a Managed Library
      1. Visibility
      2. Accessing Legacy Libraries Such as the STL
    6. It Just Works (IJW) Interoperability and the Mixed DLL Problem
      1. The Loader-Lock Bug
      2. A Sample Mixed DLL that Needs Library Initialization
      3. Initializing the CRT Library
    7. Mixing Your Own Managed and Unmanaged Code
      1. Using ILDASM to Explore Assemblies
      2. Turning Off /clr for a Single File
    8. In Brief
  12. 7. Building DLLs in Unmanaged C++
    1. What Is a DLL?
    2. Creating a DLL
      1. Writing DLL Header Files
      2. Creating the Sample DLL
    3. How to Use a DLL from Unmanaged C++
      1. The dumpbin Utility
      2. Implicit Linking to a DLL
      3. Explicit Linking to a DLL
    4. How to Use an Unmanaged DLL from Managed C++
      1. Using the Import Library
      2. Using PInvoke to Control Marshaling
      3. Writing a Custom Marshaler
        1. The Custom Marshaling Class
        2. GetInstance()
        3. MarshalManagedToNative()
        4. CleanUpNativeData()
        5. Changing the DllImport Attribute and the Calling Code
    5. How to Use an Unmanaged DLL from C#
    6. In Brief
  13. 8. Writing COM Components in C++
    1. COM Components and Their Place in Software Development
    2. Using ATL to Create an Unmanaged COM Component
      1. A Sample ATL Component
    3. Using a COM Component from Unmanaged C++
      1. Creating an Empty Project
      2. Creating a Dialog Box
      3. Connecting the Fields on the Dialog Box to Variables
      4. Connecting the Button on the Dialog Box to a Function
      5. Coding the Function
      6. Adjusting the Structure of the Application and Adding COM Support
      7. Debugging a COM Application
    4. Using a COM Component from Managed C++
    5. Exposing a Managed Class Library as a COM Component
      1. Adding Interfaces to the Library
      2. Generating a Type Library
      3. Adding the Library to the GAC
      4. Creating Registry Entries
      5. Testing the Component
    6. In Brief
  14. 9. Using Existing COM Components in C++
    1. Automation Concepts
    2. Using Word as a Spell Checker from Unmanaged C++
      1. Finding Your Way Around
      2. Accessing the Automation Server
      3. Creating a Smart Pointer and Calling Word Methods
      4. Putting It All Together
    3. Using Word as a Spell Checker from Managed C++
      1. Primary Interop Assemblies
      2. Creating the Sample Application
      3. The Entire Managed Application
    4. In Brief
  15. 10. Writing and Consuming a Web Service
    1. Web Service Fundamentals
    2. Writing a Web Service in Managed C++
    3. Consuming a Web Service in Managed C++
      1. Describing Web Services with WSDL
    4. Discovering Web Services
    5. Writing a Web Service in Unmanaged C++
    6. Calling a Web Service from Unmanaged C++
    7. In Brief
  16. 11. Writing a Data Layer in Managed C++
    1. Database Concepts
    2. The ADO.NET Class Library
    3. Filling a DataSet and Binding to a Control on a Form
      1. Creating the User Interface
      2. Creating the Data Layer Project
      3. Handling the Connection String
      4. Using a Configuration File
      5. Writing the Lookup() Method
      6. Using the Data Layer from the UI
    4. Using a Data Reader for Quick One-Way Access
      1. Creating the Console Application
      2. Writing the New LookupReader() Method
      3. Getting and Using the Data Reader from the Console Application
      4. Configuration Files Revisited
    5. Updating the Database with a Data Set
      1. Modifying the Data Layer
      2. Modifying the User Interface
    6. Data Sets and XML
      1. Getting XML from a DataSet
    7. Filling a Database from XML
    8. In Brief
  17. 12. Writing a Windows Service
    1. What Is a Windows Service?
    2. Creating a Simple Windows Service in Managed C++
      1. Creating the Skeleton of the Service
      2. Setting Properties and Adding an Installer
      3. Installing and Testing the Service
      4. Checking a URL
      5. Sending Email
      6. Adding Event Log Entries
    3. Debugging a Service
    4. In Brief
  18. 13. Strengthening Your Managed Applications with Security and Encryption
    1. Understanding Encryption Techniques and Technologies
      1. Ciphers, Plaintext, and Ciphertext
      2. Confidentiality, Integrity, and Authentication
      3. Symmetric and Asymmetric Cryptography
      4. Cryptography in the .NET Framework
    2. Encrypting Information
      1. Encrypting into a File
      2. Arrangements for Keys
    3. Decrypting Information
    4. Role-Based Security
      1. Determining Identity
      2. Testing for Roles
      3. Using Permissions Sets
    5. In Brief
  19. 14. Moving Layers to Different Machines with .NET Remoting
    1. Writing a Class That Will Be Available Through Remoting
    2. Writing a Remoting Client
    3. Hosting the Remoted Object and Configuring the Client
      1. Creating and Configuring the Server Application
      2. Changing the Client to Use the Remoted Object
      3. Deploying to the Remote Machine
    4. Communication Over Remoting
      1. Basics of .NET Events
      2. Changes to the Remoting Server
        1. Defining a Delegate
        2. Defining the Event Handler Base Class
        3. Changing the Greeter Class
        4. Modifying the Form
        5. Changing the Server Configuration File
        6. Implementing the Client Event Handler
        7. Changing the Client Configuration File
        8. Creating a Handler and Adding It to the List on the Server
    5. Choosing Lifetime and Lifecycle Options Appropriately
    6. In Brief
  20. 15. Building Advanced User Interfaces in Managed C++
    1. Extending Windows Controls
      1. Extending a Library Control
      2. Creating a User Control
    2. Using Drag and Drop
      1. Making a Control a Drop Target
      2. Making a Control a Drag Source
    3. Using GDI+
      1. Getting a Graphics Object
      2. Drawing with Pens
      3. Painting with Brushes
      4. Writing Text
    4. Internationalizing and Localizing a Windows Application
      1. Designing for Internationalization
      2. Localizing a Windows Application
      3. Being Localizable
    5. In Brief