Tải bản đầy đủ (.pdf) (1,372 trang)

visual basic 2010 unleashed

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (45.5 MB, 1,372 trang )

ptg
ptg
Visual Basic
®
2010
UNLEASHED
800 East 96th Street, Indianapolis, Indiana 46240 USA
Alessandro Del Sole
From the Library of Wow! eBook
ptg
Visual Basic
®
2010 Unleashed
Copyright © 2010 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval
system, or transmitted by any means, electronic, mechanical, photocopying, recording,
or otherwise, without written permission from the publisher. No patent liability is
assumed with respect to the use of the information contained herein. Although every
precaution has been taken in the preparation of this book, the publisher and author
assume no responsibility for errors or omissions. Nor is any liability assumed for
damages resulting from the use of the information contained herein.
ISBN-10: 0-672-33154-3
ISBN-13: 978-0-672-33154-1
Library of Congress Cataloging-in-Publication Data
Del Sole, Alessandro.
Visual Basic 2010 unleashed / Alessandro Del Sole.
p. cm.
Includes index.
ISBN 978-0-672-33100-8
1. BASIC (Computer program language) 2. Microsoft Visual BASIC. I. Title.
QA76.73.B3D467 2010


005.2'768 dc22
2010012721
Printed in the United States of America
First Printing: May 2010
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks
have been appropriately capitalized. Pearson Education, Inc. cannot attest to the accu-
racy of this information. Use of a term in this book should not be regarded as affecting
the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possi-
ble, but no warranty or fitness is implied. The information provided is on an “as is”
basis. The author and the publisher shall have neither liability nor responsibility to any
person or entity with respect to any loss or damages arising from the information
contained in this book.
Bulk Sales
Pearson offers excellent discounts on this book when ordered in quantity for bulk
purchases or special sales. For more information, please contact:
U.S. Corporate and Government Sales
1-800-382-3419

For sales outside of the U.S., please contact:
International Sales
+1-317-581-3793

Editor-in-Chief
Karen Gettman
Executive Editor
Neil Rowe
Acquisitions Editor

Brook Farling
Development Editor
Mark Renfrow
Managing Editor
Patrick Kanouse
Project Editor
Mandie Frank
Copy Editor
Apostrophe Editing
Services
Indexer
WordWise Publishing
Services LLC
Proofreader
The Wordsmithery
LLC
Technical Editor
Matt Kleinwaks
Publishing
Coordinator
Cindy Teeters
Designer
Gary Adair
Compositor
Mark Shirar
From the Library of Wow! eBook
ptg
Contents at a Glance
Part I Learning the Basics of VB
1 Introducing the .NET Framework 4.0 1

2 Getting Started with the Visual Studio 2010 IDE 11
3 The Anatomy of a Visual Basic Project 59
4 Data Types and Expressions 85
5 Debugging Visual Basic 2010 Applications 177
6 Handling Errors and Exceptions 207
Part II Object-Oriented Programming with Visual Basic 2010
7 Class Fundamentals 225
8 Managing an Object’s Lifetime 267
9 Organizing Types Within Namespaces 281
10 Modules 295
11 Structures and Enumerations 299
12 Inheritance 317
13 Interfaces 341
14 Generics and Nullable Types 359
15 Delegates and Events 371
16 Working with Collections 385
17 Visually Designing Objects 407
18 “Generate From Usage” Coding Techniques 421
Part III Advanced VB Language features
19 Manipulating Files and Streams 429
20 The My Namespace 451
21 Advanced Language Features 485
Part IV Data Access with ADO.NET and LINQ
22 Introducing ADO.NET and DataSets . 513
23 Introducing LINQ 523
24 LINQ to Objects 531
25 LINQ to SQL 561
26 LINQ to DataSets 595
From the Library of Wow! eBook
ptg

27 Introducing ADO.NET Entity Framework 603
28 Manipulating Xml Documents with LINQ and Xml Literals 635
29 Overview of Parallel LINQ 655
Part V Building Windows Applications
30 Creating Windows Forms 4.0 Applications 665
31 Creating WPF Applications 681
32 WPF Common Controls 715
33 Brushes, Styles, Templates, and Animations in WPF 745
34 Manipulating Documents and Media 781
35 Introducing Data-Binding 799
36 Localizing Applications 829
Part VI Building Web Applications
37 Building ASP.NET Web Applications 839
38 Publishing ASP.NET Web Applications 865
39 Building Rich Internet Applications with Silverlight 871
40 Building and Deploying Applications for Windows Azure 899
Part VII Networking and Exposing Data Through Networks
41 Creating and Consuming WCF Services 927
42 Implementing and Consuming WCF Data Services 949
Part VIII Advanced .NET Framework with VB 2010
43 Serialization 971
44 Processes and Multithreading 993
45 Parallel Programming 1005
46 Working with Assemblies 1029
47 Reflection 1043
48 Coding Attributes 1065
49 Platform Invokes and Interoperability with the COM Architecture 1075
50 Documenting the Source Code 1091
51 Advanced Compilations with MSBuild 1105
52 Building Customizations for Microsoft Office 1119

Part IX Applications Deployment
53 Understanding the Global Assembly Cache . 1137
54 Setup & Deployment Projects for Windows Installer . 1145
55 Deploying Applications with ClickOnce. 1159
Visual Basic 2010 Unleashed
iv
From the Library of Wow! eBook
ptg
Part X Mastering the Visual Studio 2010 IDE
56 Advanced IDE Features . 1175
57 Introducing the Visual Studio Extensibility . 1199
58 Advanced Analysis Tools. 1223
59 Testing Code with Unit Tests, Test-Driven Development, and
Code Contracts 1251
Appendixes
A Installing Visual Studio 2010. 1275
B Useful Resources and Tools for Visual Basic. 1281 Index.
1285
Contents at a Glance
v
From the Library of Wow! eBook
ptg
Table of Contents
Part I Learning the Basics of VB
1 Introducing the .NET Framework 4.0 1
What Is the .NET Framework?. 1
Where Is the .NET Framework . 2
The .NET Framework Architecture . 2
The Common Language Runtime . 4
Writing Managed Code 4

.NET Assemblies. 5
The Base Class Library 5
.NET Languages. 6
.NET Framework Tools . 7
Windows Software Development Kit 7
What’s New in .NET Framework 4.0 . 8
2 Getting Started with the Visual Studio 2010 IDE
11
What’s New in Visual Studio 2010 11
Start Page. 12
Get Started Tab 13
The Guidance and Resources Tab 13
The Latest News Tab 14
Working with Projects and Solutions . 15
Creating Visual Basic Projects 16
Multitargeting. 17
Accessing Recent and Online Templates 18
Searching for Installed Templates 20
Creating Reusable Projects and Items Templates 21
Creating Your First Visual Basic 2010 Project 21
Finding Visual Basic Projects. 23
Working with the Code Editor 24
Working with Tool Windows. 26
The Solution Explorer Window 27
Error List Window . 28
The Properties Window . 30
Output Window. 31
My Project . 31
Application Tab 33
From the Library of Wow! eBook

ptg
Compiling Projects 37
Debug and Release Configurations . 38
Other Compile Options. 41
Advanced Compile Options . 44
Debugging Overview 47
Debugging an Application 47
Breakpoints and Data Tips . 49
About Runtime Errors. 52
Edit and Continue . 53
Browsing the Visual Basic and .NET Documentation . 54
Online Help and the MSDN Library . 55
Object Browser Window. 55
3 The Anatomy of a Visual Basic Project
59
Brief Overview of Types and Members. 59
Classes 60
Properties 60
Methods 60
Modules 61
Structures 61
Inheritance 61
Namespaces 62
Accessing Members 63
Imports Directives 64
#Region #End Region Directives 64
Attributes 65
A New Feature: Implicit Line Continuation 65
Visual Basic 2010 Reserved Keywords . 67
Understanding Project Files. 70

Dissecting My Project 70
Application.MyApp . 70
AssemblyInfo.vb . 72
Resources and the Resources.resx File 73
Application Settings. 77
Understanding References . 79
Adding References to COM Libraries . 82
Deploy Without PIAs. 83
Final Considerations. 84
4 Data Types and Expressions
85
Common Type System. 85
Everything Is an Object 86
Contents
vii
From the Library of Wow! eBook
ptg
Introducing Value Types and Reference Types 86
System.Object and System.ValueType 87
Understanding Value Types. 89
.NET Framework Primitive Value Types 90
Using Value Types 92
Working with BigInteger 100
Building Custom Value Types 101
Understanding Reference Types . 101
.NET Framework Primitive Reference Types 103
Differences Between Value Types and Reference Types . 104
Memory Allocation 104
Object-Oriented Differences 107
Performance Differences 109

What Custom Type Should I Choose? 109
Converting Between Value Types and Reference Types. 110
Understanding Implicit Conversions 110
Boxing and Unboxing . 112
Deep Copy and Shallow Copy 114
The
GetType Keyword 118
Conversion Operators. 119
Widening and Narrowing Conversions 119
Working with .NET Fundamental Types . 124
Working with Strings 125
Working with Dates 137
Working with Time. 143
Working with TimeZone and TimeZoneInfo 144
Working with GUIDs 147
Working with Arrays. 148
Common Operators . 155
Arithmetic Operators 155
Assignment Operators 157
Logical, Bitwise and Shift Operators 158
Concatenation Operators 163
Comparison Operators 164
Iterations, Loops, and Conditional Code Blocks . 166
Iterations 166
Loops 169
Conditional Code Blocks 171
Constants 174
With End With statement 175
Visual Basic 2010 Unleashed
viii

From the Library of Wow! eBook
ptg
5 Debugging Visual Basic 2010 Applications 177
Preparing an Example 177
Debugging Instrumentation 178
Debugging in Steps 178
Mixed Mode Debugging 180
“Just My Code” Debugging 180
Working with Breakpoints and Trace Points 182
Locals Window . 185
Command Window . 185
Call Stack Window . 186
Watch Windows. 187
Threads Window. 189
Autos Window . 190
Debugger Visualizers 191
Debugging in Code 192
The
Debug Class 192
The Trace Class 194
Understanding Trace Listeners . 195
Using Debug Attributes in Your Code 201
6 Handling Errors and Exceptions
207
Introducing Exceptions 207
Handling Exceptions 208
Are You Upgrading from Visual Basic 6? . 209
System.Exception, Naming Conventions and Specialization 209
Try Catch Finally 209
The Throw Keyword . 218

The When Keyword . 222
Catching Exceptions Without a Variable 224
Part II Object-Oriented Programming with Visual Basic 2010
7 Class Fundamentals
225
Declaring Classes. 225
Nested Classes 226
Fields . 227
Avoiding Ambiguities with Local Variables . 228
Properties. 229
Read-Only Properties 231
Write-Only Properties 231
Contents
ix
From the Library of Wow! eBook
ptg
Exposing Custom Types 232
Accessing Properties. 232
Default Properties . 233
Scope 234
Methods 236
Invoking Methods 236
Methods Arguments: ByVal and ByRef 237
Overloading Methods 242
Exit from Methods 245
Partial Classes 246
Partial Methods 249
Constructors 251
Overloading Constructors 254
Object Initializers. 256

Shared Members 257
Shared Classes 258
Shared Fields . 258
Shared Properties 259
Shared Methods 259
Shared Constructors 261
Common Language Specification. 262
Where Do I Need to Apply? . 262
Marking Assemblies and Types as CLS-Compliant 263
Naming Conventions . 263
Rules About Classes . 265
Rules About Properties. 265
Rules About Methods . 265
Rules About Arrays 266
8 Managing an Object’s Lifetime
267
Understanding Memory Allocation 267
Understanding Garbage Collection 268
Understanding the
Finalize Method 269
Understanding Dispose and the IDisposable Interface 271
Using End Using Statement 273
Putting Dispose and Finalize Together 273
Object Resurrection 276
Advanced Garbage Collection 277
Interacting with the Garbage Collector . 277
Understanding Generations and
Operation Modes 278
Visual Basic 2010 Unleashed
x

From the Library of Wow! eBook
ptg
9 Organizing Types Within Namespaces 281
Understanding What Namespaces Are. 281
Organizing Types Within Namespaces 282
Why Are Namespaces So Useful? 285
Nested Namespaces. 286
Scope . 289
Root Namespace . 289
Global Keyword. 290
Imports Directives . 291
Namespaces and Common Language Specification 294
10 Modules
295
Modules Overview 295
Scope 296
Differences Between Modules and Classes 297
No Constructor 297
No Inheritance Support 297
No Interface Implementation 297
11 Structures and Enumerations
299
Assignments 302
Passing Structures to Methods 302
Members’ Visibility 303
Inheritance Limitations and Interfaces Implementation 303
Memory Allocation . 303
Organizing Structures 304
Overloading Operators 305
Overloading

CType 307
Structures and Common Language Specification . 308
Enumerations . 309
Using Enumerations 310
Useful Methods from System.Enum 311
Using Enums As Return Values From Methods 314
Enum Values As Bit Flags 315
Enumerations and Common Language Specification 315
12 Inheritance
317
Applying Inheritance 318
Illustrating System.Object in Detail 321
Introducing Polymorphism 323
Overriding Members . 325
Contents
xi
From the Library of Wow! eBook
ptg
NotOverridable Keyword 328
Overloading Derived Members . 328
Conditioning Inheritance 328
NotInheritable Keyword 329
MustInherit and MustOverride Keywords 330
Accessing Base Classes Members . 331
MyBase Keyword 332
MyClass Keyword 334
Constructors’ Inheritance 335
Shadowing. 336
Overriding Shared Members 337
Practical Inheritance: Building Custom Exceptions 338

13 Interfaces
341
Defining Interfaces 341
Implementing and Accessing Interfaces 343
Passing Interfaces As Method Arguments . 345
Interfaces and Polymorphism. 345
Interfaces Inheritance . 346
Defining CLS-Compliant Interfaces . 347
Most Common .NET Interfaces . 348
The
IEnumerable Interface 348
The IComparable Interface 351
The IConvertible Interface 353
The IFormattable Interface 356
14 Generics and Nullable Types
359
Introducing Generics 359
Creating and Consuming Generics 360
Consuming Generic Types 362
Implementing Generic Methods 363
Understanding Constraints . 363
Overloading Type Parameters. 366
Introducing Nullable Types 367
15 Delegates and Events
371
Understanding Delegates. 371
Declaring Delegates 372
Combining Delegates: Multicast Delegates 374
Handling Events. 375
Registering for events:

AddHandler and RemoveHandler 375
Declaring Objects with the WithEvents Keyword. 377
Visual Basic 2010 Unleashed
xii
From the Library of Wow! eBook
ptg
Offering Events to the External World. 378
Raising Events 378
Creating Custom Events 381
16 Working with Collections
385
Understanding Collections Architecture. 385
Working with Nongeneric Collections 386
The ArrayList Collection 386
The Queue Collection. 389
The Stack Collection. 390
The HashTable Collection 390
The ListDictionary Collection 391
The OrderedDictionary Collection 391
The SortedList Collection 392
The HybridDictionary Collection 392
The StringCollection Collection 392
The StringDictionary Collection 393
The NameValueCollection Collection 393
The BitArray Collection . 393
The Bitvector32 Collection 394
Working with Generic Collections . 395
The List(Of T) Collection 395
Working with Collection Initializers 397
The ReadOnlyCollection(Of T) Collection 398

The Dictionary(Of TKey, TValue) Collection 399
The SortedDictionary(Of TKey, TValue) Collection 400
The ObservableCollection(Of T) Collection 400
The ReadonlyObservableCollection(Of T) Collection 402
The LinkedList(Of T) Collection 403
The Queue(Of T) and Stack(Of T) Collections 405
Building Custom Collections 405
Concurrent Collections 406
17 Visually Designing Objects
407
Visual Studio Class Designer. 407
Enabling the Class Designer. 408
Adding and Designing Objects 409
Implementing Derived Classes. 413
Creating Multiple Diagrams . 416
Exporting the Diagram . 416
Class View Window 417
Class Details Window 418
Contents
xiii
From the Library of Wow! eBook
ptg
18 “Generate From Usage” Coding Techniques 421
Coding New Types 421
Generating Shared Members . 425
On-the-Fly Code and Object Initializers 425
Generating Complex Objects 426
Interfaces Additions 428
Part III Advanced VB Language features
19 Manipulating Files and Streams

429
Manipulating Directories and Pathnames. 429
The System.IO.Path Class 430
The System.IO.Directory Class 431
The System.IO.DirectoryInfo Class 434
The System.IO.DriveInfo Class 434
Handling Exceptions for Directories and Pathnames . 435
Manipulating Files . 436
The System.IO.File Class 436
The System.IO.FileInfo Class 438
Handling File Exceptions. 439
Understanding Permissions. 439
Introducing Streams 440
Reading and Writing Text Files 441
Reading and Writing Binary Files 442
Using Memory Streams . 442
Using Streams with Strings 443
Compressing Data with Streams 444
Networking with Streams . 448
20 The My Namespace
451
Introducing
My 451
My.Application 452
Retrieving Assembly Information . 452
Working with Cultures . 453
Deployment and Environment Information 454
My.Computer 456
Working with the File System 457
Working with the Clipboard . 458

Playing Audio Files . 459
Managing the Keyboard . 460
Working with the Registry . 460
Accessing the Network . 461
Getting Computer Information . 462
Visual Basic 2010 Unleashed
xiv
From the Library of Wow! eBook
ptg
My.Settings . 464
My.Settings Events 469
My.Resources . 470
Getting Resources by Name in Code . 474
My.User. 474
My.WebServices. 476
Extending My. 476
Extending My.Application and My.Computer 478
Extending My.Resources and My.Settings . 480
My in Different Applications . 480
Understanding Application Events 483
21 Advanced Language Features
485
Local Type Inference 485
Option Infer Directive 487
Local Type Inference Scope . 488
Array Literals 489
Multidimensional and Jagged Arrays . 489
Extension Methods . 490
Coding Custom Extension Methods. 495
Exporting Extension Methods. 497

Anonymous Types 498
Relaxed Delegates. 500
Lambda Expressions 500
Type Inference and Lambda Expressions . 503
Multiline Lambdas. 504
Sub Lambdas. 505
Lexical Closures . 506
Ternary
If Operator 507
Generic Variance. 509
Covariance 509
Contra Variance 510
Part IV Data Access with ADO.NET and LINQ
22 Introducing ADO.NET and DataSets
513
Introducing ADO.NET . 513
Data Providers 514
Connection Modes 515
Understanding Connections and Data Readers 515
Introducing DataSets . 517
Creating DataSets 517
Contents
xv
From the Library of Wow! eBook
ptg
23 Introducing LINQ 523
What Is LINQ? 523
LINQ Examples 525
Language Support . 526
Understanding Providers 527

Overview of LINQ Architecture 528
24 LINQ to Objects
531
Introducing LINQ to Objects 531
Querying in Memory Objects 532
Understanding Deferred Execution. 539
Introducing Standard Query Operators. 541
Projection Operators 542
Restriction Operators 543
Aggregation Operators 544
Understanding the Let Keyword 546
Conversion Operators 546
Generation Operators 548
Ordering Operators. 549
Set Operators. 550
Grouping Operators 551
Union Operators. 553
Equality Operators. 556
Quantifiers . 556
Concatenation Operators 557
Elements Operators 557
Partitioning Operators 558
25 LINQ to SQL
561
Introducing LINQ to SQL . 561
Prerequisites 562
Understanding LINQ to SQL Classes 562
Behind the Scenes of LINQ to SQL Classes 573
Querying Data with LINQ to SQL . 574
Insert/Update/Delete Operations with LINQ 579

Inserting Entities 579
Updating Entities 583
Deleting Entities 584
Mapping Stored Procedures 584
Using the Log 587
Advanced LINQ to SQL. 588
Custom Validations 588
Visual Basic 2010 Unleashed
xvi
From the Library of Wow! eBook
ptg
Handling Optimistic Concurrency 590
Using SQL Syntax Against Entities 591
LINQ to SQL with SQL Server Compact Edition. 592
Writing the Connection String 593
26 LINQ to DataSets
595
Querying Datasets with LINQ . 595
Building Complex Queries with Anonymous Types . 598
LINQ to DataSets’ Extension Methods. 598
Understanding CopyToDataTable . 598
Understanding Field(Of T) and SetField(Of T) 600
27 Introducing ADO.NET Entity Framework
603
Introducing Entity Framework 603
Understanding Entity Data Models 604
Understanding the ObjectContext class:
The Visual Basic Mapping . 612
Entity Designer Tool Windows 617
Insert/Update/Delete Operations for Entities. 620

Instantiating the ObjectContext. 620
Adding Entities . 623
Deleting Entities . 624
Updating Entities. 625
Handling Optimistic Concurrency. 626
Validating Data . 627
Querying EDMs with LINQ to Entities. 628
Querying EDMs with Entity SQL. 629
Mapping Stored Procedures . 631
28 Manipulating Xml Documents with LINQ and Xml Literals
635
Introducing LINQ to Xml. 635
The
System.Xml.Linq Namespace. 636
Xml Literals. 641
LINQ Queries with Xml Literals 644
Understanding Embedded Expressions 646
Xml Schema Inference 649
29 Overview of Parallel LINQ
655
Introducing PLINQ . 655
Simulating an Intensive Work 656
Measuring Performances of a Classic LINQ Query 656
Contents
xvii
From the Library of Wow! eBook
ptg
Measuring Performances of a PLINQ Query 657
Ordering Sequences . 659
AsParallel and Binary Operators. 660

Using ParallelEnumerable 660
Controlling PLINQ Queries . 661
Handling Exceptions 663
Part V Building Windows Applications
30 Creating Windows Forms 4.0 Applications
665
What Windows Forms Is Today 665
Creating Windows Forms Applications 666
What’s New in Windows Forms 4.0 667
Available Windows Forms Controls . 667
Building Windows Forms Applications with ADO.NET
Entity Framework and Chart Control. 668
Providing Custom Validation 674
Understanding Chart Control 675
Populating the Chart Control 677
Running the Sample Application 680
31 Creating WPF Applications
681
What Is WPF? 682
Improvements in WPF 4 682
WPF Architecture . 683
Building WPF Applications with Visual Studio 2010 685
Understanding the eXtensible Application Markup Language (XAML) 687
Declaring and Using Controls with the Designer and XAML. 689
Understanding Visual Tree and Logical Tree. 692
Handling Events in WPF. 694
A More Thorough Discussion: Introducing the Routed Events . 695
Arranging Controls with Panels . 697
The
Grid Panel 697

The StackPanel Panel 700
The WrapPanel Panel 701
The Canvas Panel 703
The DockPanel Panel 703
The ViewBox Panel 704
Managing Windows. 704
Instantiating Windows at Runtime 706
Introducing the Application Object 707
Brief Overview of WPF Browser Applications 710
Visual Basic 2010 Unleashed
xviii
From the Library of Wow! eBook
ptg
32 WPF Common Controls 715
Introducing WPF Controls Features 715
Understanding the ContentControl 716
Understanding Common Controls 717
Border 717
Button 718
Calendar 718
CheckBox 719
ComboBox 720
DataGrid 721
DatePicker 721
DocumentViewer 723
Ellipse 723
Expander 723
Frame . 724
GroupBox 725
Image . 726

Label . 726
ListBox 727
ListView 728
MediaElement 729
Menu . 729
PasswordBox 732
ProgressBar 732
RadioButton 734
Rectangle 734
RichTextBox 734
ScrollBar 735
ScrollViewer 735
Separator 736
Slider 736
StatusBar 737
TabControl 737
TextBlock 738
TextBox 739
ToolBar 740
TreeView 741
WebBrowser 742
WindowsFormsHost 742
Using Common Dialogs 743
Contents
xix
From the Library of Wow! eBook
ptg
Visual Basic 2010 Unleashed
xx
33 Brushes, Styles, Templates, and Animations in WPF 745

Introducing Brushes. 745
Applying a SolidColorBrush. 747
Applying a LinearGradientBrush 748
Applying a RadialGradientBrush 749
Applying an ImageBrush. 751
Applying SelectionBrush and CaretBrush 753
Applying a VisualBrush . 754
Applying a DrawingBrush . 755
Applying a BitmapCacheBrush 757
Introducing Styles . 759
Styles Inheritance 761
Understanding Triggers 761
Introducing Control Templates 763
Introducing Transformations. 766
Applying
RotateTransform . 767
Applying ScaleTransform . 767
Applying SkewTransform . 768
Applying TranslateTransform 768
Applying Multiple Transforms . 769
Introducing Animations 770
Applying DoubleAnimation . 771
Applying ColorAnimation . 773
Working with Animation Events . 775
Creating Animations with Visual Basic. 776
34 Manipulating Documents and Media
781
Viewing Images 781
Playing Media . 783
Manipulating Documents 786

Understanding the RichTextBox Control . 795
Viewing XPS Documents 796
35 Introducing Data-Binding
799
Introducing the Data-Binding . 799
Binding UI Elements with the Binding Markup Extension. 800
Understanding the DataGrid and the ObservableCollection 802
Discussing the New Drag’n’Drop Data-Binding. 806
Creating Tabular Data Forms. 807
Creating Master-Details Forms 813
Understanding Views and Binding Lists 818
Implementing String Formatters and Value Converters 822
From the Library of Wow! eBook
ptg
36 Localizing Applications 829
Introducing .NET Localization 829
Windows Forms Localization 830
WPF Localization . 832
Preparing the LocBaml tool. 832
Localizing a WPF Application 833
Part VI Building Web Applications
37 Building ASP.NET Web Applications
839
Introducing the ASP.NET Model. 839
Understanding Page Requests 840
Scalability and Performances. 840
Available Project Templates . 841
Web Forms and Master Pages 842
Web Forms 842
ASP.NET Controls. 845

Server Controls 845
HTML Controls 847
Handling Events 848
Understanding State Management 848
The
Application State 849
The Cache State. 849
The Context State . 850
Using Cookies for Saving Information 850
The Session State . 851
The ViewState State . 851
Creating a Web Application with VB 2010 with
Navigation and Data-Binding 851
Master Pages 852
Adding the Data Model 855
Adding a New Web Form 855
Adding Data Controls 857
Adding Filtering Capabilities 860
Adding Navigation Controls 861
Running the Application 861
Configuring a Web Application for Security . 863
38 Publishing ASP.NET Web Applications
865
Deployment Overview. 865
The 1-Click Deployment 866
Classic Publishing . 866
Contents
xxi
From the Library of Wow! eBook
ptg

MSDeploy Publish. 868
Understanding Packages 868
Deploy with MSDeploy 868
39 Building Rich Internet Applications with Silverlight
871
Introducing Silverlight 871
Creating Silverlight Projects with Visual Basic 2010 872
Adding Controls and Handling Events 875
How Silverlight Applications Are Packaged . 876
Playing Media . 876
Animating UI Elements . 880
Introducing Navigation Applications. 882
Introducing WCF RIA Services . 886
Adding the Data Source 887
Adding the Domain Service Class 887
Data-Binding to Controls 891
Running the Application 893
“Out of Browser” Applications 894
40 Building and Deploying Applications for Windows Azure
899
About Windows Azure Platform. 899
Registering for the Windows Azure Developer Portal 901
Downloading and Installing Tools for Visual Studio 901
Additional Tools 902
Creating a Demo Project. 902
Understanding Web Roles and Web Configuration 902
Adding a Silverlight 3 Project. 905
Testing the Application Locally. 911
Deploying Applications to Windows Azure . 913
Activating the Storage Account . 921

Using the Windows Azure Management Console Snap-In 922
Part VII Networking and Exposing Data Through Networks
41 Creating and Consuming WCF Services
927
Introducing Windows Communication Foundation. 928
Understanding Endpoints . 928
Address, Binding, Contract: The ABC of WCF 928
Implementing WCF Services 929
Implementing Custom Logic for the WCF Service. 933
Consuming WCF Services. 937
Creating the Client and Adding a Service Reference. 938
Visual Basic 2010 Unleashed
xxii
From the Library of Wow! eBook
ptg
Understanding the Proxy Class 938
Invoking Members from the Service 939
Handling Exceptions in WCF 943
Hosting WCF Services in Internet Information Services 944
Configuring Services with the Configuration Editor 945
42 Implementing and Consuming WCF Data Services
949
What Are Data Services? 949
Querying Data via Http Requests. 950
Implementing WCF Data Services. 951
Deploying WCF Data Services to Internet Information Services . 957
Consuming WCF Data Services . 957
Creating a Client Application . 957
Querying Data . 962
Implementing Service Operations 963

Implementing Query Interceptors 965
Understanding Query Interceptors . 965
Understanding Change Interceptors 967
Understanding Server-Driven Paging 968
Part VIII Advanced .NET Framework with VB 2010
43 Serialization
971
Objects Serialization 972
Binary Serialization 972
Soap Serialization 975
Providing Serialization for Custom Objects 976
NonSerialized events 978
XML Serialization 979
Customizing Xml Serialization . 980
Custom Serialization. 982
Serialization Events 983
Serialization with XAML. 984
Serialization in Windows Communication Foundation 987
JSON Serialization 989
Serialization in the ADO.NET Entity Framework 990
44 Processes and Multithreading
993
Managing Processes . 994
Querying Existing Processes . 995
Introducing Multithreading . 996
Creating Threads 996
Passing Parameters 997
Contents
xxiii
From the Library of Wow! eBook

ptg
Understanding the .NET Thread Pool . 997
Getting and Setting Information in the Thread Pool. 998
Threads Synchronization. 999
The SyncLock End SyncLock Statement 1000
Synchronization with the Monitor Class. 1001
Read/Write Locks . 1001
45 Parallel Programming
1005
Introducing Parallel Computing 1006
Introducing Parallel Classes. 1006
Understanding and Using Tasks 1007
What Is a Task? 1007
Running Tasks with Parallel.Invoke 1008
Creating, Running, and Managing Tasks: The Task Class 1009
Creating Tasks That Return Values 1009
Exception Handling 1011
Cancelling Tasks . 1012
The Barrier Class 1014
Parallel Loops . 1015
Parallel.For Loop 1017
Parallel.ForEach Loop 1018
Debugging Tools For Parallel Tasks 1021
Concurrent Collections . 1022
ConcurrentBag(Of T) 1023
ConcurrentQueue(Of T) 1024
ConcurrentStack(Of T) 1024
ConcurrentDictionary(Of TKey, TValue) 1025
BlockingCollection(Of T) 1026
46 Working with Assemblies

1029
Assembly Overview. 1029
Information Stored Within Assemblies 1030
Assembly Location. 1030
Signing Assemblies . 1031
Assembly Information and Attributes. 1031
Understanding Application Domains. 1031
Creating Application Domains and Executing Assemblies 1031
Overview of Security Changes in .NET 4.0 . 1034
Permissions 1035
The Transparency Level 2 1036
Sandboxing 1038
Conditional APTCA 1041
Migrating from Old CAS-Based Code 1041
Visual Basic 2010 Unleashed
xxiv
From the Library of Wow! eBook

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×