Introduction... xxi. Chapter 1: Introducing Visual Basic In Depth... 2

Similar documents
Introduction... xxxix. Part I:.NET Framework 4.0 and Visual Studio Chapter 1: Getting Started with.net Framework

Chapter 1 Getting Started with Windows Presentation Foundation

CHAPTER 1: INTRODUCING C# 3

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

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

CHAPTER 1: INTRODUCTION TO THE IDE 3

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

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

Apex TG India Pvt. Ltd.

ALPHAPRIMETECH 112 New South Road, Hicksville, NY 11801

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

Introduction... xxxvii. Part I:.NET Framework 4.0 and Visual Studio Chapter 1: C#.NET Essentials... 1

DOT NET SYLLABUS FOR 6 MONTHS

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

DOT NET Syllabus (6 Months)

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

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

Visual Basic 2008 How to Program, 4/E Outline

Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500

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

C#.NET TRAINING / /

.Net. Course Content ASP.NET

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

Microsoft Visual C# Step by Step. John Sharp

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

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

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

Beginning ASP.NET. 4.5 in C# Matthew MacDonald

Chapters are PDF documents posted online at the book s Companion Website (located at

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( )

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

Microsoft ASP.NET Whole Course Syllabus upto Developer Module (Including all three module Primary.NET + Advance Course Techniques+ Developer Tricks)

C# 2008 and.net Programming for Electronic Engineers - Elektor - ISBN

OVERVIEW ENVIRONMENT PROGRAM STRUCTURE BASIC SYNTAX DATA TYPES TYPE CONVERSION

Uka Tarsadia University MCA ( 3rd Semester)/M.Sc.(CA) (1st Semester) Course : / Visual Programming Question Bank

Dot Net Online Training

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

CHAPTER 1: VISUAL STUDIO

C# Syllabus. MS.NET Framework Introduction

Murach s Beginning Java with Eclipse

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

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

Pro ODP.NET for Oracle. Database 11 g. Edmund Zehoo. Apress

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

"Charting the Course to Your Success!" MOC B Programming in C# Course Summary

.NET FRAMEWORK. Visual C#.Net

"Charting the Course... MOC C: Developing SQL Databases. Course Summary

DOT NET COURSE BROCHURE

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank)

.NET-6Weeks Project Based Training

"Charting the Course... Java Programming Language. Course Summary

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

Contents. Illustrations. 1 Introduction to Computers, the Internet, the Web and C# 1

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

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

10262A VB: Developing Windows Applications with Microsoft Visual Studio 2010

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

Introduction. Part I: Silverlight Fundamentals for ASP.NET Developers 1

Programming Microsoft LINQ in

.NET Advance Package Syllabus

VB.NET Web : Phone : INTRODUCTION TO NET FRAME WORK

DOT.NET MODULE 6: SILVERLIGHT

Diploma in Microsoft.NET

Before You Begin. and Visual Basic 1

Excel Programming with VBA (Macro Programming) 24 hours Getting Started

Programming in Visual Basic with Microsoft Visual Studio 2010

CETPA INFOTECH PVT. LTD.

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

"Charting the Course... MOC Programming in C# with Microsoft Visual Studio Course Summary

Level: M.Ed. Credit Hour: 3 (2+1) Semester: Third Teaching Hour: 80(32+48)

Microsoft. Inside Microsoft. SharePoint Ted Pattison. Andrew Connell. Scot Hillier. David Mann

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

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

Windows Presentation Foundation Programming Using C#

Acknowledgments Introduction. Chapter 1: Introduction to Access 2007 VBA 1. The Visual Basic Editor 18. Testing Phase 24

PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore

Microsoft Visual Studio 2010

C# Programming Syllabus

Table Of Contents VISUAL BAISC 2005 FOR BEGINNERS

Advanced WCF 4.0 .NET. Web Services. Contents for.net Professionals. Learn new and stay updated. Design Patterns, OOPS Principles, WCF, WPF, MVC &LINQ

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.)

B.V Patel Institute of Business Management, Computer & Information Technology

Pro Business Applications with Silverlight 4

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

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

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

Program Contents: DOTNET TRAINING IN CHENNAI

Programming in C# for Experienced Programmers

Programming in C#

[CHAPTER] 1 INTRODUCTION 1

HCIM SUMMER WORKSHOP Introduction to C#

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank)

Coding Faster: Getting More Productive with Microsoft Visual

This page intentionally left blank

Subject to Change Drawing Application 1 Introducing Computers, the Internet and C#

20483BC: Programming in C#

6 Months Training Module in.net Module 1-Total Days-20

Developing Web Applications

Acknowledgments Introduction. Part I: Programming Access Applications 1. Chapter 1: Overview of Programming for Access 3

Transcription:

Introduction... xxi Chapter 1: Introducing Visual Basic 2008... 1 In Depth... 2 New Features Introduced in Visual Basic 2008... 2 Language Improvements in Visual Basic 2008... 2 Compiler Changes and Options in Visual Basic 2008... 6 Keywords... 6 Visual Basic Statements... 8 Statement Syntax... 9 The Option and Imports Statements... 10 The Option Statements... 10 The Imports Statement... 11 Namespaces... 11 System Namespaces... 12 Data Types... 14 Variables and Constants... 15 Declaring Variable... 15 Constant Declaration... 18 Data Type Conversion... 19 Operators... 21 Operator Precedence... 23 Arrays... 25 Standard Arrays... 25 Dynamic Arrays... 26 Enumerations... 26 Strings... 26 Immediate Solutions... 28 Creating a Console Application... 28 Using the Option Statement... 29

Using the Imports Statement... 29 Creating Aliases for Namespace Classes... 30 Declaring Variables and Constants... 30 Converting Data Types... 31 Creating Standard Arrays... 32 Creating Dynamic Arrays... 33 Creating Enumerations... 33 Working with Strings... 34 Using the Val and Str Functions... 35 Commenting Your Code... 36 Summary... 36 Chapter 2: Flow Control and Exception Handling in Visual Basic 2008... 37 In Depth... 38 Control Flow Statements... 38 Selection Statements... 38 Iteration Statements... 40 The Jump Statements... 42 The With Statement... 43 Sub procedures and Functions... 43 Understanding Scope... 45 Block Scope... 46 Procedure Scope... 47 Module Scope... 47 Namespace Scope... 48 Exception Handling... 48 Structured Exception Handling... 49 Unstructured Exception Handling... 50 Immediate Solutions... 52 Using the If Else Statement... 52 Using the Select Case Statement... 52 Using the While Statement... 53 Using the Do While Statement... 54 Using the For Statement... 55 Using the For Each Statement... 56 Using the With Statement... 57 Jumping to the Labeled Statement... 58 Breaking Out of a Loop... 59 Using the Continue Statement... 60 Creating Sub procedures... 61 Passing Variable Number of Arguments to a Procedure... 62 Specifying Optional Procedure Arguments... 62 vi

Creating Functions... 63 Using the On Error Resume Next Statement... 64 Using the On Error Statement... 64 Capturing an Exception... 65 Throwing an Exception... 66 Summary... 66 Chapter 3: Object-Oriented Programming in Visual Basic 2008... 67 In Depth... 68 Classes and Objects... 68 Constructors and Destructors... 68 Shared Members... 69 Access Modifiers... 69 Structures and Modules... 70 Encapsulation... 71 Inheritance... 71 Inheritance Modifiers... 72 Extension Methods... 72 Polymorphism... 73 Compile Time Polymorphism/Overloading... 73 Runtime Polymorphism/Overriding... 75 Shadowing... 75 Abstraction... 76 Abstract Classes and Abstract Methods... 76 Interface... 77 Syntax of Interfaces... 78 Implementation of Interfaces... 78 Interface and Inheritance... 79 Immediate Solutions... 80 Creating a Class... 80 Creating a Constructor... 80 Creating an Object... 81 Creating Shared Members... 82 Using the Is and IsNot Operators to Compare Two Objects... 83 Creating Destructors... 84 Using the Finalize Method... 84 Using the Dispose Method... 85 Creating Structures... 86 Implementing Inheritance... 87 Creating an Extension Method... 87 Implementing Early Binding/Overloading... 88 Implementing Late Binding/Overriding... 89 vii

Implementing Shadowing... 90 Using the MyBase Keyword... 91 Using the MyClass Keyword... 92 Creating Abstract Classes and Abstract Methods... 93 Using the NotInheritable and NotOverridable Keywords... 94 Creating and Implementing Interfaces... 95 Summary... 96 Chapter 4: Windows Forms in Visual Basic 2008... 97 In Depth... 98 All about Windows Forms... 98 Immediate Solutions... 103 Creating Windows Forms Applications... 103 Adding Controls to Windows Forms... 104 Disabling and Enabling Windows Forms... 105 Changing the Title of Windows Forms... 106 Setting the Border of Windows Forms... 107 Displaying and Hiding the Maximize, Minimize, and Close Buttons of Windows Forms... 108 Specifying the Initial Position of Windows Forms... 108 Creating Multiform Windows Applications... 109 Setting the Startup Form... 112 Displaying Messages... 113 Using the MsgBox Function... 113 Using the MessageBox.Show Method... 115 Using Windows Forms to Create Dialog Boxes... 118 Creating a Dialog Box... 118 Displaying and Reading Data from Dialog Boxes... 119 Creating the Accept and Cancel Buttons... 119 Creating Owned Windows Forms... 120 Creating Always-On-Top Windows Forms... 121 Performing Some Common Operations on Controls... 122 Hiding and Displaying Controls... 122 Disabling and Enabling Controls... 124 Specifying the Tab Order of Controls... 125 Specifying Access Characters for Controls... 127 Moving and Resizing Controls... 128 Adding a Control at Runtime... 129 Handling Common Events for Windows Forms and Controls... 130 Handling Mouse Events... 131 Handling Keyboard Events... 131 Specifying the Mouse Cursor for Windows Forms and Controls... 134 Summary... 138 viii

Chapter 5: Windows Forms Controls... 139 In Depth... 140 The Control Class... 140 The Button Control... 146 The Label Control... 147 The TextBox Control... 148 The RichTextBox Control... 150 The MaskedTextBox Control... 153 The MenuStrip Control... 155 The ToolStripMenuItem Class... 157 The ContextMenuStrip Control... 158 Immediate Solutions... 160 Using the Button Control... 160 Setting the Captions of Buttons... 160 Setting the Background and Foreground Colors of Buttons... 161 Adding an Image to a Button... 162 Handling the Click Events of Buttons... 164 Handling Button Releases... 165 Using the Label Control... 166 Formatting the Text in Labels... 166 Handling the Click and DoubleClick Events of Labels... 168 Using Labels to Specify Access Keys for Other Controls... 168 Using the TextBox, RichTextBox, and MaskedTextBox Controls... 169 Adding Text to TextBox, RichTextBox, and MaskedTextBox Controls... 169 Restricting Characters in TextBox Controls... 170 Controlling the User Input with MaskedTextBox Controls... 171 Using the MenuStrip and ContextMenuStrip Controls... 172 Adding Menu Items... 173 Adding Submenus... 174 Disabling and Enabling Menu Items... 176 Hiding and Displaying Menu Items... 177 Displaying Checkmarks on Menu Items... 178 Displaying a Separator between the Menu Items... 179 Setting Access Keys for Menu Items... 180 Setting the Shortcut Keys for Menu Items... 181 Adding Images to the Menu Items... 182 Creating Context Menus... 184 Associating a Context Menu with another Controls... 185 Summary... 186 ix

Chapter 6: Introducing Windows Presentation Foundation... 187 In Depth... 188 Main Features of WPF 3.5... 188 Improved Application Model... 188 Improved Controls... 189 Support for Data Validation and Data Binding Models and LINQ... 189 Support for High-End Text Rendering, Typography, and Documents... 189 Enhanced Support for 2-D and 3-D Graphics, Animation, and Multimedia... 190 WPF 3.5 Architecture... 190 PresentationFramework... 191 PresentationCore... 191 WindowsBase... 191 MIL or Milcore... 191 WPF 3.5 Class Hierarchy... 192 The System.Windows.Threading.DispatcherObject Class... 192 The System.Windows.DependencyObject Class... 192 The System.Windows.Freezable Class... 193 The System.Windows.Media.Visual Class... 193 The System.Windows.UIElement Class... 193 The System.Windows.FrameworkElement Class... 194 The System.Windows.Controls.Control Class... 194 The System.Windows.Controls.Panel Class... 194 The System.Windows.Shapes.Shape Class... 195 The System.Windows.ContentElement Class... 195 WPF 3.5 Application Model... 195 Types of WPF Applications... 195 The Application Class... 202 Exploring the WPF 3.5 Designer Interface... 204 Design View... 205 XAML View... 209 Split View Bar... 210 Tag Navigator... 212 Solution Explorer... 212 Properties Window... 213 Toolbox... 214 Document Outline Window... 214 Using XAML in WPF 3.5 Applications... 215 XAML Elements... 215 Namespaces and XAML... 216 XAML Property Syntax... 217 Markup Extensions... 218 WPF Properties... 220 x

Dependency Properties... 220 Attached Properties... 228 WPF Events... 230 Routed Events... 230 Attached Events... 235 Lifetime Events... 236 Working with Dialog Boxes in WPF Applications... 237 The MessageBox Class... 238 The OpenFileDialog Class... 238 The SaveFileDialog Class... 238 The PrintDialog Class... 239 Compiling and Running WPF 3.5 applications... 239 Immediate Solutions... 242 Working with WPF Windows... 242 Adding Rows and Columns to a Grid Through XAML... 245 Creating a Dialog Box in a WPF 3.5 Application... 247 Using a Message Box... 247 Using the Print Dialog Box... 248 Working with Custom Routed Events... 250 Summary... 252 Chapter 7: Using Graphics and Multimedia in Windows Forms and WPF... 253 In Depth... 254 Graphics in Windows Forms Applications... 254 GDI+ Managed Class Interface... 254 Basic GDI+ Managed Classes... 255 Graphics, Animation, and Multimedia in WPF 3.5... 261 2-D Graphics... 262 The DrawingContext Class... 270 3-D Graphics... 271 Animation in WPF 3.5... 275 Multimedia in WPF 3.5... 285 Immediate Solutions... 292 Using Graphics in Windows Forms... 292 Using 2-D Graphics in WPF 3.5... 294 Using 2-D Shapes... 294 Creating Stretchable Shapes... 295 Drawing Geometry... 296 Combining Multiple Geometries... 297 Transforming Shapes... 298 Using the Path Shape and PathGeometry Geometry... 299 xi

Using Brushes... 301 Changing the Tile Size and the Pattern of Brushes... 304 Creating Reflections using VisualBrush... 305 Preserving the Aspect Ratio of Image... 307 Using 3-D Graphics in WPF 3.5... 308 Creating 3-D Models... 308 Using DrawingBrush to Apply Material on 3-D Models... 309 Adding Cameras... 311 Adding Lights... 314 Transforming 3-D Models... 318 Using Animation in WPF 3.5... 322 Creating Animations Using Storyboards... 323 Changing the Speed of Animations... 326 Reversing the Animation... 328 Controlling the Behavior of Animation... 329 Specifying the Behavior of Animation after Ending... 330 Running Multiple Animations Simultaneously... 331 Controlling Storyboards Interactively... 332 Using DoubleAnimation to Transform Controls... 335 Creating Local Animations... 337 Using Keyframe Animation... 338 Animating Geometries... 343 Using Animation with 3-D Models... 343 Using Multimedia in WPF 3.5... 347 Displaying Images using the Image Control... 347 Transforming Images... 348 Stretching Images... 349 Using MediaElement to Control the Media Playback... 351 Adding Media Using MediaPlayer... 352 Using Storyboard to Control the Media Playback... 353 Playing a Media on a User Event... 355 Transforming a Video in MediaElement... 358 Summary... 360 Chapter 8: Introducing Windows Communication Foundation... 361 In Depth... 362 WCF Client-Server Architecture... 362 Instancing Model of WCF Services... 362 per-call Instancing Service... 363 per-session Instancing Service... 364 Sharable Instancing Service... 365 Singleton Instancing Service... 366 xii

WCF Layers... 366 Contracts... 367 Service Runtime... 367 Messaging... 368 Hosting and Activation... 368 WCF Endpoints... 369 Endpoint Addresses... 370 Bindings... 370 Service Contracts... 372 Behaviors... 375 Configuration of WCF Services... 375 WCF Clients... 377 WCF Service Identity... 378 WCF and ASP.NET AJAX... 378 Immediate Solutions... 380 Creating WCF Services... 380 Creating a Service Contract and Defining the Operations... 380 Implementing the Service Contract... 380 Configuring the Service... 381 Hosting WCF Services... 385 Using the WCF Service... 396 Creating a WCF Client... 396 Configuring the WCF Client... 401 Calling Operations of a WCF Service... 401 Using WCF Services with ASP.NET AJAX... 403 Creating an ASP.NET AJAX Enabled WCF Service... 403 Calling WCF Services from Client-side Scripts... 406 Summary... 410 Chapter 9: Data Access with ADO.NET... 411 In Depth... 412 Introducing Databases... 412 Introducing SQL... 412 The SELECT Statement... 413 The WHERE Clause... 413 The LIKE Clause... 413 The DISTINCT Clause... 413 The Logical Operations... 414 The ORDER BY Clause... 414 The GROUP BY Clause... 414 The DELETE Statement... 414 The UPDATE Statement... 414 xiii

Joining Tables... 414 The DROP Statement... 415 Introducing ADO.NET... 415 Describing the Architecture of ADO.NET... 416 ADO.NET Entity Framework... 419 Immediate Solutions... 421 Creating Connection Strings... 421 Syntax for connection strings... 424 Creating a Connection to a Database... 425 SQL Server Database... 425 OLEDB Database... 430 ODBC Data Source... 437 Creating a Command Object... 445 Working with DataAdapters... 446 Creating DataSet from DataAdapter... 446 Paging with Data Adapters... 447 Updating with Data Adapters... 449 Adding Multiple Tables to a DataSet... 450 Creating DataView... 451 Using DataReader to Work with Databases... 453 Summary... 454 Chapter 10: Data Binding in Windows Forms and WPF Applications... 455 In Depth... 456 Basic Data Binding Concepts... 456 Types of Data Binding... 456 Simple Data Binding... 457 Complex Data Binding... 457 Binding Data to Windows Forms Controls... 457 Data Binding in Windows Presentation Foundation... 458 Data Flow Directions in WPF... 458 Sources of Data Binding... 458 CLR Objects... 459 ADO.NET... 459 XML... 459 DependencyObject... 459 Declaration of Data Binding... 459 XAML Based Binding... 459 Code Based Binding... 460 Binding Path Syntax... 460 Binding to Collections... 460 ADO.NET Data Services... 460 xiv

Immediate Solutions... 462 Creating a Simple Data Binding in Windows Forms... 462 Creating a Complex Data Binding in Windows Forms... 466 Binding Windows Forms Controls... 467 Text Boxes and Labels... 467 Check Boxes... 468 Combo Boxes... 470 List Boxes... 471 Checked List Boxes... 472 MenuStrip and StatusStrip Controls... 473 Using the BindingContext Class... 475 Navigation in DataSet... 475 Using Parameterized SQL Queries... 478 Simple Binding in WPF... 479 Binding to CLR Object in WPF... 481 Binding to ADO.NET objects in WPF... 484 Binding to XML Objects in WPF... 486 DependencyObject Bindings in WPF... 487 Implementing Validation Rules with Data Binding... 488 Data binding to Web Services in WPF... 491 Creating ADO.NET Data Service Application... 495 Summary... 498 Chapter 11: Working with LINQ... 499 In Depth... 500 LINQ Queries... 500 Data Sources in LINQ Queries... 500 Deferred Execution and Immediate Execution... 501 Standard Query Operators... 501 The Filtering Operators... 502 The Projection Operators... 502 The Sorting Operators... 503 The Join Operators... 503 The Grouping Operators... 503 The Quantifier Operators... 504 The Partitioning Operators... 504 The Set Operators... 504 The Element Operators... 505 The Aggregate Operators... 505 The Conversion Operators... 505 The Generation Operators... 506 LINQ to Objects... 506 xv

Strings... 506 Reflections... 506 File Directories... 507 Introducing LINQ to ADO.NET... 507 LINQ to DataSet... 507 LINQ to SQL... 508 Introducing LINQ to XML... 508 Difference Between LINQ to XML and the DOM Method... 509 Working with XML Trees in LINQ... 509 The LinqDataSource Control... 509 Extension Methods... 512 Anonymous Types... 512 Lambda Expressions... 512 Immediate Solutions... 513 Creating a LINQ to DataSet Application... 513 Creating a LINQ to SQL Application... 514 Creating a LINQ to Object Application... 516 Creating a LINQ to XML Application... 517 A Simple LinqDataSource Application... 519 Using a LINQ Extension Method... 523 Using the Where Clause... 524 Type Filtering... 525 Using the Projection Operators... 525 Using the Sorting Operators... 526 Using the Join Clause... 527 Using the Grouping Operators... 528 Grouping with Nested Objects... 529 Using the Partitioning Operators... 530 Using the Set Operators... 530 Using the Aggregate Operators... 531 Using the Conversion Operators... 532 Using the Generation Operators... 533 Summary... 534 Chapter 12: Working with Windows Workflow Foundation... 535 In Depth... 536 Workflow Principles... 536 Components of Windows Workflow Foundation... 536 Host Process... 537 Runtime Services... 537 Runtime Engine... 537 Workflow... 537 xvi

Base Activity Library... 538 Custom Activities... 539 Types of Workflows... 540 The Sequential Workflow... 540 The State Machine Workflow... 540 Conditions and Rules in Workflows... 541 Simple Conditions... 541 The CAG Activity... 541 The PolicyActivity Activity... 542 Immediate Solutions... 543 Developing a Simple Workflow Application... 543 Implementing Conditions in Workflows... 544 Using Workflows with Windows Forms... 547 Summary... 550 Chapter 13: Collections and Generics... 551 In Depth... 552 Understanding Collections... 552 Collection Classes in.net... 553 The ArrayList Class... 553 The Hashtable Class... 555 The SortedList Class... 556 The Stack Class... 557 The Queue Class... 558 The BitArray Class... 559 Limitations of Collection Classes... 561 Generics... 562 Generic Collection Classes in.net... 563 The Generic List(Of T) Class... 563 The Generic LinkedList(of T) Class... 565 The Generic SortedList(Of TKey, TValue) Class... 566 The Generic Dictionary(Of TKey, TValue) Class... 567 The Generic SortedDictionary(Of TKey, TValue) Class... 567 The Generic Stack(Of T) Class... 568 The Generic Queue(Of T) Class... 569 The Generic HashSet(Of T) Class... 569 Immediate Solutions... 571 Working with Collection Classes... 571 Using the ArrayList Class... 571 Using the Hashtable class... 574 Using the SortedList Class... 578 Using the Stack Class... 582 xvii

Using the Queue Class... 585 Using the BitArray Class... 588 Working with Generic Collection Classes... 590 Using the Generic List(of T) Class... 591 Using the Generic LinkedList(of T) Class... 595 Using the Generic SortedList(Of TKey, TValue) Class... 601 Using the Generic Dictionary(Of TKey, TValue) Class... 605 Using the Generic SortedDictionary(Of TKey, TValue) Class... 608 Using the Generic Stack(Of T) Class... 611 Using the Generic Queue(Of T) Class... 614 Using the Generic HashSet(Of T) Class... 617 Summary... 620 Chapter 14: The My Object... 621 In Depth... 622 The My.Computer Object... 622 The My.Computer.Audio Object... 622 The My.Computer.Clipboard Object... 623 The My.Computer.Clock Object... 624 The My.Computer.FileSystem Object... 624 The My.Computer.Info Object... 625 The My.Computer.Keyboard Object... 626 The My.Computer.Mouse Object... 626 The My.Computer.Name Object... 627 The My.Computer.Network Object... 627 The My.Computer.Ports Object... 627 The My.Computer.Registry Object... 627 The My.Computer.Screen Object... 628 The My.Application Object... 629 The My.Application.Log Object... 629 The My.Application.Info Object... 629 The My.Forms Object... 630 The My.User Object... 630 The My.WebServices Object... 631 Immediate Solutions... 632 Using the My.Computer Object... 632 Using the My.Application Object... 636 Using the My.Forms Object... 639 Using the My.User Object... 643 Using the My.WebServices Object... 645 Summary... 648 xviii

Chapter 15:.NET Assemblies... 649 In Depth... 650.NET Assemblies... 650 Components of Assembly... 650 Types of Assemblies... 654 Attributes of an Assembly... 655 Assembly Signing... 657 Storage for Assemblies... 660 Assembly Information File... 661 Configuration Files for Assemblies... 662 Immediate Solutions... 665 Creating a Shared Assembly... 665 Strong Naming the Assembly... 665 Putting the Assembly in Global Assembly Cache... 666 Creating a Simple Client... 666 Creating a New Version of the Shared Assembly... 667 Using New Version of Shared Assembly... 668 Side-by-Side Execution of Shared Assemblies... 670 Creating a Private Assembly... 670 Creating a Multifile Assembly... 672 Native Image Generation... 674 Delayed Signing... 675 Configuring Assembly Lookup... 676 Configuring Probing... 676 Configuring CodeBase for Signed Assemblies... 678 CodeBase Settings for Unsigned Assemblies... 680 Creating Publisher Policies... 680 Summary... 680 Chapter 16: Security in.net... 681 In Depth... 682 Code Verification and Security in.net Framework... 682 Type-Safe and Verifiably Type-Safe MSIL Code... 683 Authentication and Authorization... 685 Role-Based Security... 685 Principal Object... 686 Identity Object... 687 Role-Based Security Checks... 688 Code Access Security (CAS)... 692 Security Policies... 692 Evidence... 693 xix

Code Groups... 694 Permission Sets... 696 Privileged Code and Security Demands in CAS... 698 Immediate Solutions... 701 Determining Whether Code is Verifiably Type Safe... 701 Using Role-Based Security to Authenticate and Authorize Users... 703 Performing Role-Based Security Checks... 709 Modifying Existing Code Groups... 713 Creating Code Groups... 717 Creating Permission Sets... 722 Calculating the Permission Grant of Code... 725 Calculation of Permissions at a Policy Level by Code Group Traversal... 725 Intersection of Permissions at all the Policy Levels... 725 Specifying Permission Requirements in the Code... 726 Understanding Stack Walk... 728 Modifying Stack Walk... 731 Avoiding Stack Walk with Link Demands... 732 Partially Trusted Assemblies... 733 Allowing Partial Trust Callers... 734 Security Caveats... 735 Understanding Sandboxing... 735 Extracting Public Key out of a Strong Named Assembly... 736 Summary... 736 Glossary... 737 Index... 745 What s on the CD-ROM... 749 xx