About the Book
Microsoft Visual Basic
.NET 2003 Unleashed is a premium reference guide and a must-have for anyone
currently developing or beginning to develop .NET applications. A primer
on the basic fundamentals of .NET programming is supplemented by plenty
of practical application development covering virtually every aspect of
.NET programming. It is a comprehensive, easy-to-use book designed to lay
flat, making it an ideal desk reference. You will also receive access to
an online reference tool that contains fully searchable content and code
samples. Unleashed will give you the knowledge you crave to master Visual
Basic .NET 2003.
Related
Books
Teach Yourself Books (Teach
Yourself Books)
Table of Contents
Introduction.
Overview of Visual Basic
Visual Basic .NET (and C#)
Visual Basic .NET 2003 Unleashed
How This Book Is Organized
Part I: Fundamentals
Part II: Windows Forms Applications
Part III: Database Programming
Part IV: Web Applications (ASP.NET)
Part V: Advanced Programming
Part VI: Securing Applications
Part VII: Remoting
Part VIII: Web Services
Part IX: Enterprise Services
How to Use This Book
I. FUNDAMENTALS.
1. Introduction to .NET.
Software as a Service
.NET Products
.NET Services
.NET Framework
Objectives of the .NET Framework
Understanding the .NET Framework Architecture
Understanding the Role of the .NET
Framework
What Is MSIL?
What Is a Portable Executable (PE)
File?
Understanding the JIT Compiler
Common Language Runtime
Components of the Common Language
Runtime
.NET Framework Class Library
Advantages of the Common Language
Runtime
What Is an Assembly?
Structure of an Assembly
How Assembly Enables XCOPY Deployment
and Zero-Impact Install
Design Considerations of an Assembly
Types of Assemblies
Metadata
Common Language System (CLS)
Summary
Further Reading
2. Language Fundamentals.
Variable Declaration
Keyword Meaning
Declaration Levels
Declaring Data Type
Declaring Lifetime
Declaring Scope
Declaring Accessibility
Variables and Assignment
Use of Namespaces
Imports Keyword
Using Aliases
How to Create Modules in Visual Basic
.NET
Creating Multiple Modules
Control Structures
If/Then Selection Structure
If/Then/Else Selection Structure
Select/Case Statement
While Repetition Structure
DoWhile/Loop Repetition Structure
Do/LoopWhile Repetition Structure
DoUntil/Loop Repetition Structure
Do/LoopUntil Repetition Structure
For/Next Repetition Structure
ForEach/Next Repetition Structure
Exit Statement
Assignment Operators
Logical Operators
Conditional Statements
How to Code Conditional Expressions
and Use Them in Conditional Statements
Using Assignment Operators
Constants
Using Operators
Built-In Functions
Conversion Functions
String-Manipulation Functions
Other Useful Functions
Writing Your Own Routines
Subroutines
Functions
Scope of Variables
Why Is Scope Important?
Summary
Further Reading
3. Object-Oriented Programming Fundamentals.
Object-Oriented Concepts
Creating Classes
Creating Basic Classes
Objects, Classes, and Instances
Creating Constructors
Composition of an Object
Working with Objects
Object Declaration and Instantiation
Object References
Dereferencing Objects
Handling Events
Handling Events
Handling Multiple Events
The WithEvents Keyword
Raising Events
Receiving Events
Inheritance in Visual Basic .NET
Overriding Methods
Summary
Further Reading
4. .NET Framework Data Types.
What Is the Common Type System?
System.Object: The Root of Everything
Types and Aliases
Getting to Know Data Types
Garbage Collection
Value Types
Reference Types
The System.String Class
Mutable Strings
The StringBuilder Object
What Is a GUID?
Boxing and Unboxing
Summary
Further Reading
II. WINDOWS FORMS APPLICATIONS.
5. Windows Forms.
Creating a New Project
How to Run a Project
Introduction to Forms
The Form Class
Modifying a Form's Properties
Changing the Name of a Form
Displaying Text on a Form's Title
Bar
Changing a Form's Background Color
Adding an Image to a Form's Background
Displaying an Icon in the Form
Specifying the Initial Display Position
of a Form
Controlling Size and Location of the
Form
Application Object
Controlling the Appearance of the
Form
Showing and Unloading Forms
Showing Forms
Configuring Control Boxes
Form Methods
Dealing with Display Issues
Resetting Properties
Event Handling
The Message Loop
Form Events
Controlling Execution
Keyboard and Mouse Events
Summary
Further Reading
6. Controls.
Working with the Visual Studio .NET
Form Designer
The Toolbox Window
The Properties Window
Adding Event Handlers
Working with the Form Control
TextBox Control
Creating a Password Text Box
Creating a Read-Only Text Box
Events Raised by the TextBox Control
The Button Control
Selecting a Button Control
Responding to a Button Click
The Label Control
The RadioButton Control
The CheckBox Control
Responding to Check Box Clicks
The ListBox Control
Selecting Items in the ListBox Control
Finding Items in a ListBox Control
Manipulating Items in a ListBox Control
Common Methods Supported by the List
Controls
The ComboBox Control
Menu
Building the Menu Groups
Adding Menu Levels
Creating Menus Programmatically
Adding a Menu Shortcut
Adding Hotkeys
Responding to the Click Event
User Interface Control Events for
MenuItems
Defining a MenuItem as a Separator
Arranging Menu Items
Right-to-Left Menus
Context Menu
Summary
Further Reading
7. Drawing.
The Graphics Device Interface (GDI)
GDI+: A Higher-Level API
Features of GDI+
GDI+ Namespaces in .NET
System.Drawing Namespace
System.Drawing.Design Namespace
System.Drawing.Printing Namespace
System.Drawing.Imaging Namespace
System.Drawing.Drawing2D Namespace
System.Drawing.Text Namespace
The Graphics Class
Common Graphics Objects
Drawing Lines
Drawing Basic Shapes
Filling Shapes
Collections of Shapes
Working with Images
Unit of Measurement
Working with Fonts
Summary
Further Reading
8. Deploying Your Application.
Introduction to Deployment
Planning for Deployment
Structure of an Assembly
Deployment Options Supported by .NET
Using XCOPY to Deploy Applications
Using Visual Studio .NET Installer
to Deploy Applications
Trade-Offs Between XCOPY and Windows
Installer
Different Types of Deployment Project
Templates Provided by Visual Studio .NET
Creating an Installer Package
Configuring Deployment Properties
Configuring Project Properties
Different Types of Setup Editors
Configuring File System Editor
Configuring Registry Editor
Configuring File Types Editor
Configuring Custom Actions Editor
Configuring Launch Conditions Editor
Configuring User Interface Editor
Building the Installer Package
Installing FormattingApplication
Uninstalling the Application
Summary
Further Reading
9. Printing.
Printing in .NET
Defining a Document
Events Supported by the PrintDocument
Class
Methods of the PrintDocument Class
Printing a Document
Using the Print Dialogs
Using PrintPreviewDialog Control
Using PrintDialog Control
Using the PageSetupDialog Control
Using PrintPreviewControl
Dealing with Settings
PrinterSettings Class
Role of PageSettings Class in Printing
Summary
Further Reading
10. Advanced Windows Forms Techniques.
Adding Controls Dynamically in Code
Dynamic Event Hookup
Creating Owned Forms
MDI Interfaces
Implementing Inheritance with Visual
Studio .NET
The NotifyIcon Control
The Use of Providers in Windows Forms
Applications
HelpProvider
Providing Help in a Windows Forms
Application
Providing Help Using ToolTips
Dialog Box Controls
Using Cursors in Windows Forms Applications
Advanced User Interface Controls
The TreeView Control
The DateTimePicker Control
The MonthCalendar Control
Summary
Further Reading
III. DATABASE PROGRAMMING.
11. ADO.NET Classes.
Data Providers
The SqlClient and OleDb Data Providers
The Connection Object
ConnectionString Property
Open() Method
Close() Method
BeginTransaction() Method
The Command Object
Preparing a Command Object to Execute
an SQL Statement
Preparing a Command Object to Call
a Stored Procedure
Preparing a Command Object to Call
a TableDirect
Execute Methods of the Command Object
The DataReader Object
The DataSet Object
Strongly Typed versus Weakly Typed
DataSets
Subordinate Objects of the DataSet
The DataView Object
The DataAdapter Object
Using the DataAdapter Wizard to Generate
a Connection String
Concurrency Violations
Illustrative Applications on the Code
Website
The TransactionsAndDataSets Application
The TransactionInteractionExplorer
Application
The ConcurrencyViolator Application
Summary
Further Reading
12. Creating and Maintaining a Database
in Visual Studio.
Creating a Database
Creating and Updating Database Components
Creating a New Table
Design of the Instructor Table
Defining a Primary Key
Considerations for Primary Key Styles
The Completed Instructor Table Design
Naming the Instructor Table
Design of the Student Table
Design of the Course Table
Design of the Enrollment Table
Editing a Table Design
A Few Words on Data Types for Those
with a Microsoft Access Background
Retrieve Data from Table
School Database Diagram
Creating a New Relationship
Course-Instructor Relationship
Enrollment-Course Relationship
Enrollment-Student Relationship
The Completed Database Diagram
Saving a Database Diagram
Examining a Table's Properties
Creating a New View
Hiding Panes in the View Design Windows
Displaying Records from a View
Saving the View
Retrieving Data from a Closed View
Considerations with Respect to Ordering
Views
Creating a Stored Procedure
Editing a Stored Procedure
Creating a Stored Procedure Using
the SqlDataAdapter
Creating a Function
Database Maintenance Operations You
Can't Do with Visual Studio
Summary
Further Reading
13. Using the Data Form and DataAdapter
Wizards in Windows Applications.
Wizard Overview
Creating the Data Form
What the Wizard Creates
Examining the Generated Code
Variable Declarations
Instantiations and Initializations
Methods Created by the Data Form Wizard
Methods Used as Event Handlers
Non-Event Handler Methods
Code Walkthrough for Various Functional
Operations
Loading Data
Updating Data
Canceling All Changes
Adding a Record for a Publisher
Deleting a Publishers Record
Canceling Changes to a Publishers
Record
Navigating the Publishers Table
Breaking Away from the Data Form Wizard
Creating a SqlClient Data Form Using
the Data Form Wizard and the SqlDataAdapter Wizard
Next Steps
Summary
Further Reading
14. Data Binding in Windows Applications.
Overview of Data Binding
Data Binding Categories: Read-Only
vs. Read-Write, and Simple vs. Complex
Potential Data Sources and Support
for the IList Interface
.NET Classes That Implement the IList
Interface
The BindingContext
The CurrencyManager Object
The PropertyManager Object
Data-Bound Objects
Simple Binding: The TextBox Control
Complex Binding: The ComboBox Control
The DataGrid Control
Matching the Data Source in Navigational
Statements to the Data Source in a Data Binding
Binding Form Controls to a DataSet
Binding an Object Property to a Table
Value
Important BindingContext and DataSet
Methods
Using the CurrencyManager for Nontable
Bindings
Binding Multiple Form Controls to
Different Properties of a Single Object
Binding Multiple Properties of One
Object to Multiple Properties of Another Object
Binding Form Controls to an ArrayList
of Objects
Read-Only Limitations of the BindingToArrayListOfObjects
Application
Read-Write Binding
Implementing Read-Write Binding to
a Custom Collection of Objects
Sample Application: ReadWriteBindableCollection
How ReadWriteBindableCollection Works
The Product Class
The Products Class
Additional Work Required to Make the
ReadWriteBindableCollection App Database Connectable
Applications on the Code Website
Summary
Further Reading
15. ADO.NET and XML.
Introduction
XML-Related Methods of the DataSet
Class
Reading and Writing XML Schemas
Effect of the Schema Information on
the Data Displayed in the DataGrid
Reading XML Data
The ReadXmlWorkoutMachine Application
Writing XML Data
Sample Outputs from WriteXml() Calls
Creating an XmlReader Using a Command
Object
Writing Schema Information to a DataSet
Using the DataAdapter
Applications on the Code Website
Other XML Support in the .NET Framework
and in Visual Studio
Summary
Further Reading
IV. WEB APPLICATIONS (ASP.NET).
16. Basic Web Application.
Create a Simple Web Application
Preparing the Web Server
Setting Up the Database
Creating Your Home Page Blog
Building Web Forms
Handling Data over the Web
Using Code-Behind Forms
Creating an Interactive Web Form
Using Web Controls to Add Functionality
to Pages
Getting to Know Web Controls
Building a Full-Featured UI
Handling Web Events
ASP.NET Events Revisited
Mastering Event Handling
Summary
Further Reading
17. Data Binding in Web Applications.
Binding Data to Simple Controls
Using Templated Controls to Display
Data
Event Bubbling
The Repeater
The DataList
The DataGrid
Writing "Bindable" Web Controls
Retrieving Data During Postback
The Postback Processing Model
Modifying the LoginForm Control
Summary
Further Reading
18. State Management.
Storing Application-Level Data
Storing Session-Specific Data
A Refresher on Web Sessions
Working with Sessions
Store Viewstate
Managing Cookies
A Refresher on Cookies
Working with Cookies
Summary
Further Reading
19. Caching.
Caching Static Elements
Caching Entire Pages
Caching Controls
Declarative Caching
Programmatic Caching
Summary
Further Reading
20. Website Management.
Configuring a Site
global.asax
web.config
Using the Assembly Cache for Application
Files
Tracing an ASP.NET Application
Summary
Further Reading
21. Security.
Overview of ASP.NET Security
Authenticating the Web User
Windows Authentication
Forms Authentication
Passport Authentication
Authorizing Users and Roles
Role-Based Authorization
Resource-Based Authorization
Preventing Injection Attacks
Securing Connection Strings and Other
Keys
Summary
Further Reading
22. Extending ASP.NET.
Understanding the ASP.NET HTTP Pipeline
Using HttpModules to Alter Output
Creating Custom HttpHandlers
Summary
Further Reading
V. ADVANCED PROGRAMMING.
23. Versioning and the Global Assembly
Cache.
Introduction to .NET Framework Versioning
Private Assemblies
Shared Assemblies
Strong Name Signing
Global Assembly Cache
Working with Shared Assemblies
Assigning a Strong Name to an Assembly
Adding an Assembly to the GAC
Delay-Signing an Assembly
Binding Policy for Assemblies
Application Policy Resolution
Publisher Policy Resolution
Administrator Policy Resolution
How the Common Language Runtime Binds
to an Assembly
Summary
Further Reading
24. IO and Persistence.
File Input and Output
Using the File Class
Using the FileStream Class
Using the StreamReader and StreamWriter
Classes
Using the BinaryReader and BinaryWriter
Classes
Serialization
XML Serialization
Runtime Serialization
Summary
Further Reading
25. Interoperability with COM.
Introduction to .NET Framework COM
Interoperability
How the .NET Framework Interoperates
with COM
Calling a COM Component from .NET
Framework Applications
Creating and Registering a COM Component
Creating a Runtime Callable Wrapper
for a COM Component
Creating a Runtime Callable Wrapper
Automatically
Calling a .NET Framework Component
from COM Applications
Creating a COM-Consumable Class by
Using Visual Basic .NET
Creating a COM Callable Wrapper (CCW)
Invoking a .NET Component from a COM
Application
Summary
Further Reading
26. Events and Delegates.
Introduction to Events
Defining and Raising the Events
Handling the Events
Introduction to Delegates
Defining a Delegate
Instantiating a Delegate
Invoking Delegates
Multicast Delegates
Events and Delegates
Summary
Further Reading
27. Multithreading.
Introduction to Threading
Advantages of Multithreaded Processing
Disadvantages of Multithreaded Processing
Working with Threads
Creating and Starting Threads
Thread Properties
Thread Methods
Thread Synchronization
Race Condition
Deadlocks
Synchronization Strategies
Asynchronous Programming
The .NET Framework Asynchronous Programming
Model
Getting Results from Asynchronous
Method Calls
Asynchronous Callbacks
Summary
Further Reading
28. Reflection to Extend the Framework.
Metadata
Introduction to Reflection
Reflecting on an Assembly
Reflecting on a Type
Late Binding
Summary
Further Reading
VI. SECURING APPLICATIONS.
29. Code Access Security (CAS).
Administrating Code Access Security
(CAS)
Exploring the Default Security with
the .NET Framework Configuration Tool
Configure Your System for Maximum
Security
Relax Security for Software Development
Deploying CAS Policies
How the CLR Calculates the Permission
Set Granted to an Assembly
Calculating the Permissions Granted
to an Assembly by the Policies
Applying Assembly-Level Attributes
to Modify the Permissions Granted
How to Use Security Demands
Simple Demands and Stack Walks
Link Demands
Inheritance Demands
Signing Assemblies
Immediate Signing
Delayed Signing
Putting It All Together
Summary
Further Reading
30. User- and Role-Based Permissions.
Authorization and Authentication
Authenticated Users in .NET
Role-Based Security
Declarative Role-Based Security
Programmatic Role-Based Security
Creating Custom Principal and Identity
Objects
Summary
Further Reading
VII. REMOTING.
31. Practical .NET Remoting.
Introduction to Remoting
Windows Processes and .NET Application
Domains
Remoting and Marshalling Explained
Remoting Architecture
Simple In-Process Remoting
Explicit Remoting
Remote Object Activation Types
Remoting with Programmatic Configuration
Remoting with Declarative Configuration
Remoting Security Features
Disabling Restrictions on Remote Parameters
Managing a Remote Object's Life Cycle
How a Remote Object Controls Its Own
Lease
Renewing Leases with Explicit Lease
Renewal
Using a Sponsor to Manage a Remote
Object's Lease
Life Cycle Best Practices
One-Way Calls and Remote Events
Contexts and Services
Object, MarshalByRefObject, and ContextBoundObject
Services
Summary
Further Reading
VIII. WEB SERVICES.
32. Basic Web Services.
Web Services Protocols
Creating a Web Service
Testing a Web Service
Invoking a Web Service
Creating a Web Service That Uses Complex
Parameters
Importing a Web Service
Discovering a Web Service
Creating a Web Service Proxy
Customizing Web Services
The WebService Attribute
The WebMethod Attribute
Creating Custom SOAP Headers
Summary
Further Reading
33. Security and Web Services Enhancements.
Platform-Level Security
IIS Authentication Strategies
ASP.NET Authentication Strategies
Passing Authentication Credentials
to Web Services
Web Service Authorization
Message-Level Security
Configuring Applications for WSE
WSE Authentication
WSE Security Tokens
WSE Authorization
WSE Security Policy
Summary
Further Reading
IX. ENTERPRISE SERVICES.
34. Introduction to Enterprise Services.
Improving Software with N-Tier Architectures
Defining Components with Interfaces
Introduction to the Architecture for
Enterprise Services
Building a Simple Serviced Component
Exploring the Component Services MMC
Plug-in
Debugging Serviced Components
Local versus Remote Deployment
Improving Your COM+ Hygiene
Adding Instrumentation and Documentation
to Serviced Components
Summary
Further Reading
35. Activation-Related Services.
Improving Scalability with Just-In-Time
Activation (JITA)
Implementing the COM+ Interface IObjectControl
Improving Performance with Object
Pooling
Combining JITA with Object Pooling
for Improved Scalability and Performance
Changing ObjectPooling Parameters
During Deployment
Passing Run-Time Arguments with Construction
String
Enabling Load Balancing
Summary
Further Reading
36. Transaction Services.
Simplify Transactional Code with COM+
Transactions
Transactions and Isolation Levels
Explained
Implementing a Transactional Component
Controlling Transaction Boundaries
and the Isolation Level
Relaxing the Isolation Requirement
with IsolationLevel
Controlling Transaction Boundaries
Combining Transactions with Pooling
and Construction Strings
Using Web Pages and Web Services as
Transaction Roots
Summary
Further Reading
37. Concurrency Protection for Serviced
Components.
Multithreading and Resource Protection
Improving the Solution with Activity-Based
Causality Locks
Controlling Activity Boundaries
Combining Activities with JITA, Transactions,
and Pooling
Summary
Further Reading
38. Services for Loosely Coupled
Systems.
Buffering Requests with Queued Components
Implementing a Simple Queued Component
Handling Errors
Queued Components, Transactions, and
Pooling
Building Publish-Subscribe Systems
with Loosely Coupled Events (LCE)
Implementing a Simple Loosely Coupled
Event
Adding Persistent Subscriptions to
an LCE
Adding Transient Subscriptions to
an LCE
Advanced LCE Topics
Summary
Further Reading
39. Securing Serviced Components.
Controlling Authentication for a COM+
Application
Implementing Role-Based Security in
COM+
Preparing a Test Project
Enabling Role-Based Security
Defining Roles and Assigning Members
Authorizing Role Members with the
SecurityRole Attribute
Authorizing Role Members Programmatically
with ContextUtil or SecurityContext
Building Trusted Subsystems with Identities
Securing Queued Components (QCs)
Securing Loosely Coupled Events
Hiding Components with the Attribute
PrivateComponent
Summary
Further Reading
40. Advanced Enterprise Services
Programming.
Programming the COM+ Catalog
Programming Transient Subscriptions
for Loosely Coupled Events
Shutting Down a COM+ Application and
Removing Components
Combining Rapid Application Development
and Enterprise Services
Summary
Further Reading
Index. |