.Net Programming with Visual C++: Tutorial, Reference, and Immediate Solutions

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Packed with C++ code examples and screen shots, .NET Programming with Visual C++ explains the .NET framework and managed extensions to C++, and provides a complete reference to the basic and advanced types contained in .NET Framework System namesp

Author(s): Max Fomitchev
Publisher: CRC Press
Year: 2003

Language: English
Pages: 710

Cover
Title Page
Copyright Page
CONTENTS SUMMARY
Table of Contents
Introduction
CHAPTER 1: Introducing the Microsoft .NET Framework
What Is .NET?
When to Upgrade to Visual C++ .NET
When Not to Upgrade
* If You Are Not Running Windows 2000 or Windows XP
* If You Rely on Third-Party Object Modules
* If You Rely on Third-Party Static Libraries that Statically Link to MFC
Web Services
Web Service Architecture
SOAP and WSDL
Web Service Discovery
Web Service Requirements
Development Challenges
Introducing Microsoft’s Solution: .NET
Sun’s Solution—Java
.NET vs. Java
Is .NET Strictly About Web Services?
Inside .NET
Cross Language Interoperability
Common Language Specification
Common Type System
Value Types
Enumerations
Classes
Interfaces
Delegates
Pointers
Microsoft Intermediate Language
Managed Execution
Metadata
Common Language Runtime
Assemblies
Assembly Manifest
Assembly Functions
Global Assembly Cache
Strong Names
Assembly Version Resolution
Assembly Security
Application Domains
The .NET Framework Class Library
System Namespace
In Summary
CHAPTER 2: Managed Extensions to C++
In Depth
Introducing Managed Extensions
Benefits of Managed Extensions
Simple Memory Management
Safer, More Robust Code
Seamless Interoperability
Wealth of the .NET Framework Class Library
Tradeoffs and Limitations of Managed Extensions
Non-deterministic Destruction
Reduced Performance
Application Deployment Issues
When to Use Managed Extensions?
Managed Code vs. Native Code
Managed C++ Project Types
Hello World in Managed C++
Immediate Solutions
Compiling Managed C++ Code
Initializing Character Strings
Declaring Namespaces (using namespace Keyword)
Referencing Namespaces (using namespace Keyword)
Importing Classes and Other Metadata from External Assemblies (#using Precompiler Directive)
Declaring Managed Classes ( gc Keyword)
Defining Managed Constructors
Defining Static Constructors
Defining Managed Destructors
Declaring Abstract Classes ( abstract Keyword)
Declaring Sealed Classes and Sealed Class Members (_sealed Keyword)
Declaring Identifiers Matching C++ Keywords ( identifier Keyword)
Declaring Properties ( property Keyword)
Declaring Indexed Properties
Declaring Interfaces ( interface Keyword)
Declaring Value Types ( value Keyword)
Boxing Value Types ( box Keyword)
Unboxing Value Types
Using Primitive Types
Declaring Managed Pointers
Using Interior and Whole Pointers
Pinning Pointers ( pin Keyword
Using Address-Of Operator
Dynamic Pointer Casting (dynamic_cast Operator)
Try-Casting (_try_cast Operator)
Static Pointer Casting (static_cast Operator)
Converting Between Unrelated Types (reinterpret_cast Operator)
Constant Casting (const_cast Operator)
C-Style Pointer Casting
Declaring Managed References
Declaring Managed Arrays
Exploiting Array Covariance
Declaring Arrays as Function Return Values
Declaring Multidimensional Arrays
Using Aggregate Array Initialization
Declaring Unmanaged Arrays
Declaring Unmanaged (_nogc) Classes
Declaring Nested Classes
Declaring Managed Enumerations
Declaring Function Pointers ( delegate keyword)
Specifying Class Visibility
Specifying Class Member Visibility
Declaring Managed Operators
Implementing Operators in Value Types
Implementing Operators in __gc-Classes
Declaring Managed Conversion Operators
Declaring Convert-To Operators
Implementing Convert-To Operators in Value Types
Implementing Convert-To Operators in __gc-Classes
Declaring Convert-From Operators
Declaring “Initialize-From” Constructors
Using Attributes
Specifying Global Attribute Context
Specifying Global Assembly Attributes
Declaring Functions with Variable Number of Arguments
Mixing Managed and Unmanaged Code
Using Unmanaged Classes as Members of Managed Types
Declaring Managed Pointers as Members of Unmanaged Classes
Passing Managed Pointers to Unmanaged Code
Creating Managed Applications
Creating Managed Class Libraries
Creating Multi-Module Assemblies
Creating Shared/Strong-Named Assemblies
Delay-Signing Assemblies
CHAPTER 3: .NET System Namespace: Arrays, Strings, Delegates And Other Essential Classe
In Depth
System Namespace Class Hierarchy
Base Interfaces
System Namespace Enumerations
System Namespace Delegates
Object Class: The Root of the Hierarchy
Array Class
String Object
String Formatting
StringBuilder Class
Console I/O
DateTime Class
Time Intervals
Math Class
Random Number Generator
Exceptions
Delegates
Multicast Delegates
Events
Immediate Solutions
Creating Arrays, Iterating Through Array Elements
Creating Arrays Dynamically
Sorting and Searching Arrays
Creating and Initializing Strings
Accessing String Characters
Concatenating Strings
Formatting Strings
Using Console I/O
Using StringBuilder Objects
Working with Dates and Time Intervals
Using Math Functions
Generating Random Numbers
Obtaining Exception Information
Working with Delegates
Using Delegates to Handle Events
CHAPTER 4: NET System Namespace: Attributes, Garbage Collector, and Other Advanced NET
In Depth
Custom Attributes
Attribute
Specifying Attribute Targets
Attribute Initialization
BitConverter Class
Buffer Class
Convert Class
Environment Class
Special Folders
Uniform Resource Identifiers
UriBuilder Class
Garbage Collector
Weak References
Immediate Solutions
Creating Custom Attribute
Obtaining Attribute Information
Accessing Numeric Types on Byte Level
Accessing Managed Arrays on Byte Level
Converting Types
Implementing Custom Type Conversion
Obtaining Environment Information
Using Uniform Resource Identifiers
Forcing Garbage Collection
Suppressing Finalization
Protecting Unmanaged Pointers to Managed Objects
Using Weak References
CHAPTER 5: Multithreaded Programming with .NET
In Depth
The System::Threading Namespace Hierarchy
Pros and Cons of Multithreading
Reasons Against Using Threads
Reasons for Using Threads
Alternatives to Using Threads
Threads
Thread States
Background Threads
Thread Local Store
Thread Local Static Fields
Thread Synchronization
Critical Sections
Manual Thread Synchronization
Wait Handles
Manual and Automatic Wait Handles
Mutexes
Monitors
Thread Pools
Wait Notification Callbacks
Performance of Thread Processing
Interlocked Exchange
Single-Writer/Multiple-Reader Access
Timers
System::Timers Namespace
System::Timers::Timer Class
Synchronized Method
Immediate Solution
Creating Threads
Aborting Threads
Using Thread Local Storage
Synchronizing Classes using the Synchronization Attribute
Synchronizing Instance and Static Methods using the Methodlmpl Attribute
Synchronizing Code Sections Using Mutexes
Synchronizing Critical Code Sections Using Monitors
Synchronizing Threads Using Wait Handles
Queuing Worker Threads in the Thread Pool
Registering Wait Notification Callbacks
Implementing Interlocked Access/Modification of Shared Numeric Variables
Implementing Single-Writer/Multiple-Reader Access to Shared Data
Using CLR Timers
Using OS/Windows Forms Timers
CHAPTER 6: Using .NET Collections
In Depth
The System::Collections Namespace
The System::Collections::Specialized Namespace
Base Interfaces
ICollection Interface
IEnumerator Interface
IList Interface
Array List Class
CollectionBase Class
ReadOnlyCollectionBase Class
String Collections
StringEnumerator Class
Collections of Sorted Name/Value Pairs
NameObjectCollectionBase:: KeysCollection Class
String Lookup Collections
Object Comparison Support
Comparer and CaselnsensitiveComparer Classes
Dictionaries
IDictionaryEnumerator Interface
Dictionary Base Class
DictionaryEntry Class
ListDictionary and HybridDictionary Classes
StringDictionary class
SortedList Class
Hash Tables
Hashtable Class
Case-Insensitive Hash Code Provider
Queues
Stacks
CollectionsUtil Clas
BitArray class
Arrays of 32-bit
Bit Sections
Immediate Solutions
Creating Dynamic Arrays, Adding and Removing Elements
Converting Between Dynamic and Fixed Arrays
Resizing Fixed-Size Arrays
Locating Dynamic Array Elements
Sorting and Searching Sorted Dynamic Arrays
Deriving Custom Collection Classes
Working with String Collections
Using Collections of Sorted Name/Value Pairs
Creating String Lookup Collections
Creating Custom Comparer Objects
Working with Dictionaries
Using String Dictionaries
Using Sorted Lists
Using Hash Tables
Using Queues
Using Stacks
Instantiating Collection Objects with the CollectionsUtil Class
Using Bit Arrays
Working with Bit Flags and Bit Sections
CHAPTER 7: .NET File and Stream I/O
In Depth
System::IO Namespace Hierarchy
Files and Directories
The Directory Class
File Class
File System Objects
Directorylnfo Class
Filelnfo Class
Streams
File Streams
Asynchronous I/O
Buffered Streams
Text Streams
TextReader Class
Text Encodings
7-bit Encoded Format
Encoded Text Stream Writer
Encoded Text Stream Reader
In-Memory Text Streams
StringWriter Class
StringReader Class
Streams for Reading/Writing Primitive Data Types
Binary Writer Clas
BinaryReader Class
In-Memory Binary Streams
File System Paths
Watching File System Changes
Isolated Storage
Isolated Storage Levels
IsolatedStorage Class
Isolated Storage Files
Isolated Storage Streams
Immediate Solutions
Using Directory Class: Retrieving and Changing Current Directory, Obtaining Directory Information
Using Directory Class: Listing Contents, Creating, Renaming, Deleting Directories
Using Directorylnfo Class: Initializing, Obtaining Directory Information, Creating Directories and Subdirectories
Using Directorylnfo Class: Listing Directory Contents, Renaming, Deleting Directories
Using File Class: Creating Files, Obtaining File Information
Using File Class: Copying, Moving Files, and Modifying File Attributes
Using Filelnfo Class: Initializing, Retrieving File Properties
Using Filelnfo Class: Modifying File Properties, Renaming and Deleting Files
Reading and Writing Files
Reading Files Asynchronously
Writing Encoded Text Streams
Reading Encoded Text Streams
Reading and Writing Primitive Data Types
Reading and Writing In-Memory Text Streams
Reading and Writing In-Memory Binary Streams
Working with Paths
Detecting File System Changes
Working with Isolated Storage
CHAPTER 8: ADO.NET: DataSets, DataTables, and XML
In Depth
ADO.NET
ADO vs.ADO.NET
ADO.NET Namespaces
System::Data Namespace Hierarchy
DataSet Class
Dataset Merging
XML Documents, XSD Schemas, and Datasets
Writing XML Data
DataRow Changes and XML DiffGrams
Reading XML Data
Reading/Writing XSD Schemas
Inferring Schemas
DataTable Class
Selecting Rows
Primary Keys
Aggregate Expressions
DataTable Notifications
Data Table Collections
DataColumn Class
Data Column Collections
DataRow Clas
Data Row Versions
Data Row Collections
Describing Relations Between Tables
Data Relation Collections
Constraints
Foreign Key Constraints
Constraint Rules
Unique Constraints
Constraint Collections
Views
DataRowView Class
Default Data View Settings
DataViewSetting Class
Data View Setting Collection
Immediate Solution
Creating Tables, Adding Columns, and Specifying Primary Keys
Using Expressions in Data Columns
Adding/Navigating Rows and Computing Aggergate Expressions
Adding/Deleting Rows and Handling DataTable Notifications
Creating Datasets, Adding Tables, and Establishing Relations
Navigating Hierarchal Datasets
Creating Unique and Foreign Key Constraints
Writing Dataset Data/Schema as XML/XSD Documents
Saving/Loading Dataset Changes as an XML DiffGram
Loading/Inferring Dataset Schemas from XSD and XML Documents
Creating Data Views
Specifying Default View Settings
CHAPTER 9: ADO.NET: OLE DB and SQL Server Data Providers
In Depth
ADO.NET Data Providers
OLE DB and SQL Server Data Providers
Database Connections
IDbConnnection Interface
Connection States
OleDbConnection and SqlConnection Classes
Data Adapters
IDataAdapter and IDbDataAdapter Interfaces
Missing Mapping Action
Missing Schema Action
DataAdapter and DbDataAdapter Classes
Filling Datasets
FillError Event
OleDbDataAdapter and SqlDataAdapter Classes
RowUpdating and RowUpdated Events
Bridge between ADO and ADO.NET
Table Mappings
Table Mapping Collections
Data Column Mappings
Data Column Mapping Collections
Database Commands
IDbCommand Interface
Command Types
Update Commands
OleDbCommand and SqlClientCommand Classes
Database Command Parameters
IDataParameter Interface
OleDbParameter and SqlParameter Classes
Identifying Command Parameters
Parameter Collections
OleDbParameterCollection and SqlParameterCollection Classes
Database Command Builders
OleDbCommandBuilder and SqlCommandBuilder Classes
Deriving Stored Procedure Parameters
Data Readers
Sequential Access to Row Data
OleDbDataReader and SqlDataReader Classes
Database Transactions
Data Transaction Levels
OleDbTransaction and SqlDbTransaction Classes
Get/Set Type Property Description
Immediate Solutions
Creating Database Connection String
Creating an OLE DB Connection String
Creating a SQL Server Connection String
Controlling Connection Pooling
Creating Database Connections
Creating and Executing Database Commands
Creating and Executing Parameterized Commands
Invoking Stored Procedures
Using Data Readers to Retrieve Database Data
Reading Hierarchal OLE DB Result Sets
Using Data Readers with Sequential Access to Read BLOB Data
Filling Dataset Schemas
Using Data Adapters to Fill Datasets
Setting Up Column and Table Mappings
Building Update, Delete and Insert Commands and Updating a Database with Dataset Changes
Handling Data Adapter Events
Working with Transactions
CHAPTER 10: Creating ASP.NET Web Services
In Depth
Web Services as Components of Distributed Computing
The Pros and Cons of Web Services
Future of Web Services
Why Use Web Services?
Minimizing Risk by Implementing a Fall Back Scheme
XML Web Services and ASP.NET
ASP.NET Web Service Overview
System::Web Namespace
ASP.NET Architecture Overview
HttpApplicationState Class
HttpSessionState Class
HttpServerUtility Class
System::Web::Services Namespace
WebService Attribute
WebServiceBinding Attribute
WebService Class
Immediate Solutions
Creating ASP.NET Web Services Using ClassWizard
Creating ASRNET Web Services Manually
Adding Web Methods to a Web Service
Debugging Web Services Locally and Remotely
Creating Web Services That Use Database Access
Using Web Services in Place of ISAPI Extensions
CHAPTER 11: Consuming Web Services Made with HTTP-GET, HTTP-POST, and SOAP
In Depth
Web Service Protocols
HTTP-GET and HTTP-POST Protocols
Simple Object Access Protocol (SOAP)
SOAP Message Architecture
SOAP Header
SOAP Body
SOAP Fault
SOAP Binding to HTTP
System:Web::Services::Protocols Namespace
Consuming Web Services
WebClientProtocol Class
HttpWebClientProtocol Class
HTTP-GET/HTTP-POST Proxy Classes
SoapHttpClientProtocol Class
SoapMessage Class
SoapClientMessage and SoapServerMessage Classes
SoapHeader Class
SoapHeaderCollection Class
SoapUnknownHeader Class
HttpMethod Attribute
SoapDocumentService and SoapRpcService Attribute
SoapDocumentMethod and SoapRpcMethod Attribute
SoapHeader Attribute
Immediate Solutions
Creating Web Service Proxies Using ClassWizard
Manually Creating Web Service Proxies That Use SOAP over HTTP
Manually Creating Web Service ProxiesThat Use HTTP-GET/HTTP-POST
Invoking Web Service Methods Synchronously and Asynchronously
Handling and Throwing Exceptions in Web Services
Managing Application and Session State
Using SOAP Headers for Exchanging Data with a Web Service
CHAPTER 12: Web Services: Definition Language (WSDL), Discovery, Security, and Configuration
Web Service Description Language (WSDL)
System::Web::Services::Description Namespace
ServiceDescription Class
Web Service Discovery
Static Discovery Files (.disco)
Dynamic Discovery Files (.vsdisco)
System::Web::Services::Discovery Namespace
DiscoveryClientProtocol Class
Discovery Document Class
The UDDI Service
Web Service Configuration
Web Service Authentication
Immediate Solutions
Discovering Web Service
Retrieving Web Service WSDL
Securing a Web Service Using Basic and Integrated Windows Authentication
Securing a Web Service Using SSL
Securing a Web Service Using Encrypted SOAP Header Authentication
CHAPTER 13: .NET Interoperability with Unmanaged Code and COM
In Depth
Interoperability with Unmanaged Code
Runtime Callable Wrappers and COM Callable Wrappers
Data Marshalling
Exception Marshalling
Class Interfaces
Generating Runtime Callable Wrappers
Metadata Conversion
Generating Runtime Callable Wrappers
Method Signature
Overloaded Methods
Assembly Registration
Importing Type Libraries
COM Smart Pointers
Deploying COM Interoperability Applications
Consuming Unmanaged DLLs
Function Prototypes
Passing Structures
COM Interoperability Attributes
Immediate Solutions
Consuming COM Components in .NET Applications
Handling COM Events in Managed Code
Consuming .NET Classes in Unmanaged Code
Handling .NET Events in Unmanaged Code
Consuming Unmanaged DLL Functions in .NET Applications
CHAPTER 14: Microsoft Extensions to C++ Languag
In Depth
Microsoft Extensions
ANSI C and C++ Standard Compliancy
Data Alignment
alignof Function
declspec(align) Keyword
aligned_xyz Functions
MMX, 3DNow!, SSE, and SSE2 Intrinsics
Immediate Solutions
Writing Portable Code
Using Interfaces
Resolving Ambiguous Interface Method Names
Catching Exceptions Thrown from Constructor’s Initialization List
Invoking Base Class Members
Overloading Functions with Covariant Return Types
Indicating Exceptions Thrown by Functions
Managing Data Alignment
Using SIMD Instruction Sets
Deprecating Functions
Managing Function Inlining
Resolving Multiple Symbol Definitions
Generating Code Conditional on Symbol Existence
Obtaining a Function Return Address
Adding Break Points Programmatically
Selectively Eliminating Function Calls
CHAPTER 15: C Runtime Library Enhancements
In Depth
C Runtime Library
Runtime Error Checking
#pragma runtime_check
Buffer Overrun Detection
Stack Overflow Recovery
Throwing new Operato
Support for Dates Beyond Year 2038
New Math Constants
Aligned Memory Allocation
Efficient Byte Swapping
Accelerating Transcendental Math Functions
Immediate Solutions
Handling Runtime Errors
Detecting Buffer Overruns
Recovering from Stack Overflows
Using Throwing new Operator
Measuring Formatted Strings
Reading Fixed-Length Formatted Data
Allocating Aligned Memory
Accelerating Math Functions with SSE
Accelerating Math Functions with 3DNow!
APPENDIX A: Visual C++ .NET Development Environment
In Depth
First Look at the Development Environment
Visual C++ .NET Installation
Setting Visual C++ .NETPreferences
Checking for Updates
Immediate Solutions
Using Solution Explorer
Using Class Wizard’s Replacement
Adding New Class Members
Adding New Classes
Adding User Interface Event Handlers
Modifying Class Properties
Using Property Window
Adding Event Handlers
Editing and Deleting Event Handlers
Adding Message Handlers
Overriding Functions
Adding New Dialog Classes
Using Resource Templates
Using Server Explorer
Setting Up Database Connections
Managing Event Logs, Message Queues, Performance Counters, and Services
Editing Source Code
Listing Class Members
Obtaining Parameter Information
Auto-Completing Keywords
Using Quick Info
Using Task List
Adding Task List Short Cuts
Removing Task List Short Cuts
Browsing Source Code
Synchronizing Class View
Outlining Source Code
Specifying Include and Library Directories
Using Configuration Manager
Setting Active Project Configuration
Building Project
Debugging Locally
Attaching to a Process
Setting Break Points
Breaking on Exceptions
Watching Variables
Using Other Debug Windows
Stepping Through Code and Stopping Debugging
APPENDIX B: MFC Application Wizard Reference
The Overview
The Application Type Page
The Compound Document Support Page
The Document Template Strings Page
The Database Support Page
The User Interface Features Page
The Advanced Features Page
The Generated Classes Page
APPENDIX C: Visual C++ .NET Project Property Pages Reference
General Page
Debug Page
C/C++ Folder
General Page
Optimization Page
Preprocessor Page
Code Generation Page
Language Page
Precompiled Headers Page
Output Files Page
Browse Information Page
Advanced Page
Linker Folder
General Page
Input Page
Debug Page
System Page
Optimization Page
Embedded IDL Page
Advanced Page
Resources Folder
MIDL Folder
Browse Information
Build Events Folder
Custom Build Step Folder
Web References Folder
Web Deployment Folder
APPENDIX D: .NET Framework System Namespace Hierarch
APPENDIX E: .NET Framework System: :Data Namespace Hierarchy
APPENDIX F: .NET Framework System: :Data:: Common, System::Data::OleDb and System::Data::SqlClient Namespace Hierarchy
Index