Programming Microsoft Visual Basic .NET (Core Reference) / Edition 1

Programming Microsoft Visual Basic .NET (Core Reference) / Edition 1

by Francesco Balena
     
 

View All Available Formats & Editions

ISBN-10: 0735613753

ISBN-13: 2900735613750

Pub. Date: 04/17/2002

Publisher: Microsoft Press

Building on the success of Programming Microsoft Visual Basic 6.0, this core reference equips new and veteran developers with instruction and code to get them up to speed with the Web-enabled Microsoft Visual Basic .NET environment. The book demonstrates best practices for porting and reusing existing Visual Basic code in the Microsoft .NET environment, as well

Overview

Building on the success of Programming Microsoft Visual Basic 6.0, this core reference equips new and veteran developers with instruction and code to get them up to speed with the Web-enabled Microsoft Visual Basic .NET environment. The book demonstrates best practices for porting and reusing existing Visual Basic code in the Microsoft .NET environment, as well as exploiting the object-oriented capabilities of the new version-complete with code samples and the book's complete text on CD-ROM.

  • Delivers instruction, sample code, best practices, and scenario-based solutions to help developers create robust, reusable, XML-enabled code with Visual Basic.NET faster—or to port existing Visual Basic code into the .NET environment
  • Details new features and capabilities, including the Class Language Runtime (CLR), the Base Common Library (BCL), and the Web Forms designer
  • Describes how to exploit the program's enhanced object-oriented capabilities, such as inheritance, multithreading, and drag-and-drop Web Service creation
  • Features entire book, sample applications, and the book’s previous edition on CD-ROM for supplemental reference and study

Product Details

ISBN-13:
2900735613750
Publisher:
Microsoft Press
Publication date:
04/17/2002
Series:
Developer Reference Series
Edition description:
BK/CDR
Pages:
1616

Table of Contents

Introductionxxv
PART I   THE BASICS 
1   Getting Started with Visual Basic .NET 3
    Why .NET? 3
        Issues with Today’s Software Development 3
        The Solution According to Microsoft .NET 9
    The Microsoft .NET Project 16
        Requirements 16
        .NET Architecture 17
        .NET Languages 20
        Microsoft Intermediate Language (MSIL) 27
        The Just-in-Time (JIT) Compiler 30
        Working with Assemblies 35
        The .NET Framework Class Library 41
    Introduction to Visual Studio .NET 48
        Old and Renewed Tools 48
        New Tools 60
        Running a Visual Basic Console Application 69
2   Modules and Variables73
    Modules and Namespaces 73
        Modules 74
        Classes 77
        Forms 79
        Namespaces 80
    Variables 87
        Declarations 87
        Data Types 92
        Initializers 98
        Assignments 100
        Arrays 111
        Structures 115
3   Control Flow and Error Handling 119
    Execution Flow Control 119
        Procedures 119
        Conditional and Loop Statements 126
        The Declare Statement 130
    Commands, Functions, and Constants 131
        String Constants 131
        String Functions 132
        Math Functions 132
        Date and Time Functions 133
        Interaction Commands and Functions 134
        Other Commands, Functions, and Objects 135
        The Environment Class 136
    Error Handling 138
        Throwing Exceptions 138
        The Exception Object 140
        The Try...Catch...Finally Statement 142
        The Throw Statement 149
        Nested Exception Objects 154
        Performance Tips 156
    Debugging .NET Applications 158
        Project and Solution Configurations 158
        Debugging Tools 160
        Tracing Application Behavior 164
PART II   OBJECT-ORIENTED PROGRAMMING 
4   Class Fundamentals 175
    Fields 175
    Methods 179
        Overloading 179
        Overloading and Coercion 182
        Ambiguous Cases 183
    Properties 184
        Read-Only and Write-Only Properties 186
        Properties with Arguments 188
        Default Properties 189
    Constructors 190
        Constructors with Arguments 190
        Overloaded Constructors 193
        Constructors and Read-Only Fields 195
    Object Lifetime 196
        COM and the Reference Counter 196
        Garbage Collection 197
        The Finalize Method 198
        The Dispose Method 201
        Object Resurrection 206
        Generations 210
        Garbage Collection and Threading 213
        Weak Object References 214
    Events 216
        Declaring and Raising an Event 216
        Trapping Events with WithEvents 217
        Trapping Events with AddHandler 218
        Module Events 222
        Trapping Events from Arrays 223
        Guidelines for Event Syntax 224
    Shared Members 227
        Shared Fields 227
        Shared Methods 229
        Shared Constructors 232
        Shared Events 234
5   Inheritance 237
    Inheritance in Previous Visual Basic Versions 237
        Inheritance by Delegation 238
        Inheritance and Late-Bound Polymorphic Code 238
        Early-Bound Polymorphic Code 239
    Inheritance in Visual Basic .NET 240
        Extending the Derived Class 241
        Using the Derived Class 241
        Inheriting Events 243
        Inheriting Shared Members 243
        Polymorphic Behavior 244
    Overriding Members in the Base Class 245
        Override Variations 247
        The MyBase Keyword 248
        Constructors in Derived Classes 249
        Finalizers in Derived Classes 251
        The MyClass Keyword 252
        Member Shadowing 255
        Redefining Shared Members 259
    Sealed and Virtual Classes 260
        The NotInheritable Keyword 260
        The MustInherit Keyword 261
        The MustOverride Keyword 262
    Scope 264
        Nested Classes 264
        Public, Private, and Friend Scope Qualifiers 267
        The Protected Scope Qualifier 268
        The Protected Friend Scope Qualifier 271
        Using Scope Qualifiers with Constructors 272
        Redefining Events 275
6   Interfaces and Delegates279
    Interfaces279
        Implementing the Interface281
        Accessing the Interface284
        Interfaces and Inheritance285
    Using .NET Interfaces286
        The IComparable Interface287
        The IComparer Interface288
        The ICloneable Interface291
        The IEnumerable and IEnumerator Interfaces294
    Delegates303
        Invoking Static Methods303
        Invoking Instance Methods306
        Other Properties307
        Defining Polymorphic Behavior307
        Delegates and Windows API Callbacks309
        Implementing Callback Procedures311
        Multicast Delegates312
7   Attributes 317
    Attribute Syntax 318
    Attributes for Visual Basic .NET 319
        The StructLayout Attribute 319
        The FieldOffset Attribute 321
        The DllImport Attribute 324
        The Conditional Attribute 326
        The Obsolete Attribute 328
        The DebuggerStepThrough Attribute 328
    Custom Attributes 329
        Building a Custom Attribute Class 329
        Discovering Attributes at Run Time 331
PART III   PROGRAMMING THE .NET FRAMEWORK 
8   .NET Framework Basic Types 337
    The System.Object Type 337
    Public and Protected Methods 338
        Value Types and Reference Types (Revisited) 340
        Boxing and Unboxing 341
    The String Type 343
        Properties and Methods 344
        String Optimizations 348
        Shared Methods 350
        The CultureInfo Auxiliary Class 351
        Formatting Numeric Values 353
        Formatting Date Values 357
        The IFormattable Interface 359
        The IFormatProvider and ICustomFormatter Interfaces 361
    The Char Type 363
    The StringBuilder Type 363
    Numeric Types 366
        Properties and Methods 366
        Formatting Numbers 368
        Parsing Strings into Numbers 369
        The Convert Class 370
        Random Number Generators 371
    The DateTime Type 372
        Adding and Subtracting Dates 373
        Formatting Dates 375
        Parsing Dates 376
        Working with Time Zones 377
    The Guid Type 378
    Enums 379
    Displaying and Parsing Enum Values 380
        Other Enum Methods 381
        Bit-Coded Values382
9   Arrays, Lists, and Collections385
    The Array Class385
        Creating Nonzero-Based Arrays387
        Copying Arrays388
        Sorting Elements389
        Clearing, Copying, and Moving Elements391
        Searching Values393
        Arrays of Arrays395
    The System.Collections Namespace396
        The ICollection, IList, and IDictionary Interfaces396
        The BitArray Class398
        The Stack Class400
        The Queue Class400
        The ArrayList Class402
        The Hashtable Class405
        The SortedList Class408
        The StringCollection and StringDictionary Classes411
    Custom Collection and Dictionary Classes413
        The ReadOnlyCollectionBase Abstract Class413
        The CollectionBase Abstract Class414
        The DictionaryBase Abstract Class417
10   Files, Directories, and Streams419
    The Directory and File Classes420
    The DirectoryInfo and FileInfo Classes425
    The Path Class428
    The Stream Class429
        Stream Operations429
        Stream Readers and Writers430
        Reading and Writing Text Files431
        Reading and Writing Binary Files434
        Reading and Writing Memory Streams435
        Reading and Writing Strings in Memory437
        Custom Stream Readers and Writers437
11   Object Serialization 441
    Basic Serialization 441
        Binary Serialization 442
        SOAP Serialization 443
        The Serializable and NonSerialized Attributes 446
        Object Graphs 447
        Deep Object Cloning 450
    Custom Serialization 452
        The ISerializable Interface 452
        A Custom Serialization Example 453
        The StreamingContext Structure 455
        The IDeserializationCallback Interface 457
    XML Serialization 460
        The XmlSerializer Class 461
        Serialization Attributes 462
        The XmlSerializerNamespaces Object 467
        Deserialization Events 468
        Overriding Behavior 469
        Working with XSD Schemas 476
12   Regular Expressions481
    Regular Expression Overview482
        The Fundamentals 482
        The Regular Expression Language 484
        Regular Expression Options 490
    Regular Expression Classes 493
        The Regex Class 493
        The MatchCollection and Match Classes 499
        The Group Class 500
        The CaptureCollection and Capture Classes 502
    Regular Expressions at Work 504
13   Threading 511
    Threading Fundamentals 511
        When to Use Threads 512
        Creating Threads 513
        Working with Threads 514
        Thread Properties 517
        Debugging Threads 519
    Storing and Sharing Data 521
        Local, Class, and Static Variables 522
        The ThreadStatic Attribute 523
        Thread Local Storage 524
        Passing Data to and from a Thread 525
        Using a Wrapper Class 529
    Thread Synchronization 532
        The SyncLock Statement 532
        Synchronized Objects 534
        The Monitor Class 536
        The Interlocked Class 539
        The Mutex Class 540
        The ReaderWriterLock Class 541
        The ManualResetEvent and AutoResetEvent Classes 543
    The ThreadPool Class 546
    Timers 548
        The System.Timers.Timer Class 548
        The System.Threading.Timer Class 549
    Asynchronous Operations 551
        Asynchronous Delegates 552
        Asynchronous File Operations 559
14   Assemblies and AppDomains 563
    Modules 563
        Headers 564
        Metadata 564
        Microsoft Intermediate Language (MSIL) 565
    Assemblies 568
        Single-File and Multiple-File Assemblies 568
        The Manifest 569
        Private and Shared Assemblies 570
        Strong Names 574
        Partial Signing and Key Containers 576
    The Binding Process 577
        Version Policy in Application Configuration Files 578
        Previously Loaded Assemblies and GAC Searches 581
        Codebase Hints 581
        Probing 582
        The Assembly Binding Log Viewer Utility (FUSLOGVW) 585
        A Real Example 586
    Configuration Files 595
        Runtime Version 596
        Garbage Collection Behavior 596
        Dynamic Properties 597
        The .NET Framework Configuration Tool 598
    Command-Line Tools 601
        The Visual Basic Compiler (VBC) 602
        The Assembly Linker (AL) 606
        The Strong Name Utility (SN) 610
        The Global Assembly Cache Utility (GACUTIL) 611
        The MSIL Disassembler (ILDASM) 612
        The Native Image Generator Utility (NGEN) 615
    Assembly Custom Attributes 617
        The AssemblyInfo.vb File 617
    The AppDomain Class 619
        Properties, Methods, and Events 619
        Creating AppDomains 623
        Catching Unhandled Exceptions 625
        The LoaderOptimization Attribute 629
15   Reflection 631
    Working with Assemblies and Modules 632
        The Assembly Class 632
        The AssemblyName Class 635
        The Module Class 637
    Working with Types 638
        Getting a Type Object 638
        Retrieving Type Attributes 640
        Enumerating Members 643
    Retrieving Member Information 650
        Enumerating Parameters 655
        Invoking Members 656
        Creating an Object Dynamically 660
        Security Issues 661
    Reflection Examples 662
        A Command-Line Type Browser 662
        Tracing the Stack Frame 668
PART IV   WIN32 APPLICATIONS 
16   Windows Forms Applications675
    Form Basics 675
        The Form Designer 676
        The Windows Forms Class Hierarchy 679
        Common Tasks for Forms and Controls 691
    The Form Object 710
        Properties, Methods, and Events 710
        Common Form Tasks 717
        Menus 731
        MDI Forms 744
    Form Inheritance 748
        Advantages of Form Inheritance 748
        An Example of Form Inheritance 748
        Trapping and Overriding Events 751
    Advanced Form Techniques 753
        Window Subclassing 753
        Transparency Effects 757
        Localized Forms 759
        Dynamic Control Properties 764
    Other Useful Objects 766
        The Clipboard Object 766
        The Application Object 773
        The Cursor Object 778
        The SendKeys Class 781
        The Help Class 782
17   Controls 785
    Windows Forms Controls 785
        The TextBox Control 785
        The Label Control 786
        The LinkLabel Control 787
        The CheckBox, RadioButton, and Button Controls 788
        The ListBox Control 790
        The CheckedListBox Control 796
        The ComboBox Control 797
        Provider Controls 798
        The Splitter Control 801
        Common Dialog Controls 803
        The ImageList Control 808
        The TreeView Control 809
        The ListView Control 813
        Other Controls 818
    Data Binding 822
        Binding to an Array of Objects 823
        ADO.NET Data Binding 829
    Custom Control Creation 835
        Inheriting from an Existing Control 836
        Improving the Custom Control 843
        Composing Multiple Controls 849
        Creating a Control from Scratch 856
        Advanced Topics 858
    Hosting Custom Controls in Internet Explorer 881
18   GDI+ 885
    2-D Vector Graphics 886
        The Graphics Object 886
        Lines, Rectangles, Polygons, Ellipses, and Arcs 887
        Cardinal and Bézier Splines 889
        The Pen Object 890
        Paths 893
        Filled Shapes 894
        Brush Objects 895
        Regions 900
        Alpha Blending 902
        Transformations 903
    Imaging 906
        Loading and Saving Images 906
        Displaying an Image 908
        Flipping, Rotating, and Skewing an Image 910
        Transparent and Semitransparent Bitmaps 913
        Icons 915
        Metafiles 916
    Typography 917
        Font Families 917
        Drawing Text 918
        Aligned Text 921
        Textual Variations 922
        Anti-Aliasing 924
19   Advanced Win32 Techniques 927
    The Registry and RegistryKey Classes 928
        Reading Registry Keys 928
    The FileSystemWatcher Component 932
        Initializing a FileSystemWatcher Component 933
        Getting Notifications 934
        Troubleshooting 937
    The Process Component 939
        Running and Stopping a Process 939
        Querying a Process for Information 943
        Waiting for a Process to End 952
    The PerformanceCounter Component 955
        Introduction to Performance Counters 955
        Reading Performance Counter Values 958
        Working with Custom Performance Counters 963
    The EventLog Component 966
        Introduction to Event Logging 966
        Reading Event Log Entries 968
        Writing Event Log Entries 971
    The ServiceController Component 974
        Listing Installed Services 975
        Querying a ServiceController Object 976
        Managing a Service 978
    Windows Service Applications 980
        Windows Service Basics 980
        Installing the Service 987
        More Service Programming Techniques 991
        Debugging a Windows Service 993
PART V   DATABASE APPLICATIONS 
20   ADO.NET in Connected Mode 997
    The Transition to ADO.NET 997
        The Limits of ADO 998
        Introducing ADO.NET 999
        .NET Data Providers 1002
        The ADO.NET Object Model 1006
    The Connection Object 1010
        Setting the ConnectionString Property 1012
        Opening and Closing the Connection 1014
        Working with Transactions 1021
    The Command Object 1025
        Creating a Command Object 1027
        Issuing Database Commands 1028
        Reading Data 1029
        Working with Parameters and Stored Procedures 1032
    The DataReader Object 1038
        Iterating over Individual Rows 1038
        Reading Column Values 1040
        Using Specific SQL Server Types 1043
        Reading Multiple Resultsets 1044
21   ADO.NET in Disconnected Mode 1047
    The DataSet Object 1048
        Exploring the DataSet Object Model 1048
        Building a DataSet 1058
    The DataAdapter Class 1083
        Introducing the DataAdapter 1084
        Reading Data from a Database 1085
        Updating the Database 1094
        Resolving Update Conflicts 1110
        Advanced Techniques 1124
22   XML and ADO.NET 1143
    Reading and Writing XML Files 1144
        The XmlTextReader Class 1144
        The XmlTextWriter Class 1152
    Working with the XML DOM 1156
        The XmlNode Class 1157
        The XmlDocument Class 1160
        The XslTransform Class 1170
    XML Features in ADO.NET 1172
        Writing XML Data 1173
        Writing the Schema and the DiffGram 1177
        Reading XML Data and Schema 1181
        Working with Strongly Typed DataSets 1183
PART VI   INTERNET APPLICATIONS 
23   Web Forms and Controls 1195
    Basic Web Forms Concepts 1195
        Your First Web Forms Project 1196
        Web Forms Dynamics 1202
    The Page Class 1211
        Page Properties 1211
        Page Methods 1214
        Page Events 1215
        Page Directives 1216
    Web Forms Controls 1222
        HTML Server Controls 1223
        Web Forms Controls 1232
        Validation Controls 1242
        List Controls 1252
        Other Controls 1256
        Data Binding with Web Forms Controls 1263
        Text Formatting in Visual Studio .NET 1273
    Template Controls 1275
        Templates 1276
        The Repeater Control 1277
        The DataList Control 1283
        The DataGrid Control 1298
        Dynamic Templates 1316
24   ASP.NET Applications 1323
    ASP.NET Intrinsic Objects 1324
        The HttpRequest Class 1325
        The HttpResponse Class 1329
        The HttpServerUtility Class 1337
        The HttpSessionState Class 1338
        The HttpApplicationState Class 1339
    State Management and Caching 1340
        Session State 1342
        Page Caching 1348
        The Cache Class 1352
        Static Variables 1359
    The Global.asax File 1360
        Global Error Handlers 1363
        Application-Wide Response Filter 1364
        Persistent Session Variables 1364
    Tracing 1368
         The Trace Property 1368
        Application-Level Tracing 1369
        The TraceContext Class 1370
    HTTP Modules and Handlers 1372
        HTTP Modules 1372
        HTTP Handlers 1375
    ASP.NET Security 1381
        Basic Concepts 1381
        ASP.NET Windows Authentication 1392
        Forms Authentication Mode 1395
        Programmatic Security 1402
    ASP.NET Configuration Files 1405
        Configuration Basics 1406
        ASP.NET Configuration Settings 1410
    ASP.NET Performance Counters 1421
25   User Controls and Custom Controls 1425
    User Controls 1426
        Your First User Control 1426
        User Controls in Visual Studio .NET 1429
        Fragment Caching 1436
    Custom Controls 1438
        Your First Custom Control 1439
        Improving the Custom Control 1446
        Composite Controls 1462
        Client-Side Script Code 1466
26   XML Web Services 1473
    Introduction to XML Web Services 1474
        Building the XML Web Service Project 1474
        Testing the XML Web Service Within the Browser 1476
        Creating an XML Web Service Client 1479
        XML Web Services Protocols 1483
        Building XML Web Services Without Visual Studio 1487
    XML Web Services Up Close 1494
        The XML Web Service Class 1494
        The WebMethod Attribute 1498
        The XML Web Service Proxy Class 1502
    Advanced Topics 1511
        SOAP Headers 1511
        XML Web Service Security 1514
        SOAP Extensions 1519
INDEX1529

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >