About the Book
Not just about Visual Basic .NET coding, this
handbook provides advanced guidance about architectural and design issues
and technology tradeoffs in large-scale, enterprise applications.
While many books cover specific technical
issues, they very rarely provide architectural guidance, which is especially
helpful with adoption of Microsoft .NET. This title educates developers
on just these topics. The expert authors—two members of the Microsoft Visual
Basic .NET product team—present technologies within the context of their
most appropriate use, and discuss design tradeoffs for large-scale applications.
They also offer advanced techniques for performance tuning, testing, and
implementation.
• Architectural Guidance - Delivers the
advanced guidance about architecture and tradeoffs that veteran developers
need, especially since .NET allows developers to choose and use far more
tools and technologies
• Applied focus - Discusses advanced technologies
and real-world consequences of design decisions in conjunction with pervasive
issues such as application performance, scalability, and security
• Expert Authors - Written by two Microsoft
Visual Basic team members who are uniquely qualified to show how best to
use Visual Basic .NET in developing enterprise applications.
Related Books
Microsoft® Visual Basic® Professional
6.0 Step by Step
Programming Microsoft® Visual Basic®
6.0
Developing Microsoft® .NET Controls
with Microsoft Visual Basic® .NET
Table of Contents
Introduction
xv
PART I MOVING TO ENTERPRISE DEVELOPMENT
WITH VISUAL BASIC .NET
1 Enterprise Application Development
and Visual Basic .NET 3
Enterprise
Application Development 3
Team Development 4
Performance, Scalability, and Reliability 4
Implementation Technologies and Integration 5
The Distributed Environment 6
The Development
Process 6
Collecting Requirements 7
Design and Architecture 8
Implementation 11
Testing 11
Deployment 12
Visual
Basic .NET 12
Visual Basic Then and Now 12
Good Coding Practices 15
Conclusion
18
2 Visual Basic .NET for the Enterprise
19
Moving
Beyond Visual Basic 6.0 21
Option
Strict Is Not Optional 21
Short-Circuiting Your Operators 26
Calling Platform Functions Directly: Declare and DllImport 29
Types
in Visual Basic .NET 32
Type Magic: Boxing and Unboxing 33
Classes and Modules 34
Structures 35
Interfaces 37
Enumeration Types 38
Delegates and Events 41
Visual
Basic and OOP 45
Making the Most of Namespaces 45
Inheritance: The Wily Beast of OOP 49
Singletons 61
Exception
Handling Redux 63
Exception Handling Basics 63
Throwing Exceptions 65
Exception Handling No-Nos 66
Custom Exceptions 67
Resource
Management and IDisposable 69
The Garbage Collector 69
The IDisposable Interface 70
Conclusion
72
3 Multithreaded Programming
73
An Overview
of Basic Threading Concepts 74
Processes and Threads 74
Creating Threads 76
Encapsulating
Threads 78
Wrapping a Thread with a Class 78
Controlling
Thread Execution 81
The ThreadState Property and the Life Cycle of a Thread 81
Referencing the Current Thread 85
Thread Control Methods 85
Tying It All Together 91
Thread
Synchronization 92
Race Conditions and You 92
Synchronization Constructs 93
Thread
Pooling 102
The ThreadPool Class 104
Conclusion
105
4 Playing Nice with Others: Native
Code and COM Interoperability 107
The PInvoke
Service 109
Calling Native Methods 110
Marshaling Types 118
Implementing Callback Functions 134
Wrapping Things Up 137
COM and
Visual Basic .NET 137
What Is COM Interop? 137
COM vs. .NET 138
What COM Interop Does 140
Using COM from Visual Basic .NET 140
Using Visual Basic .NET from COM 144
COM Threading Models 147
Performance
Considerations 147
Memory Considerations 148
Conclusion
149
PART II BUILDING AN ENTERPRISE
INFRASTRUCTURE
5 Distributed Programming in
.NET 153
Serialization
154
Serialization Formats 154
The Serializable Attribute 157
XML Web
Services 161
Getting Started 162
SOAP Header Extensions 163
Performance 166
Limitations of Web Services 168
Security 168
Remoting
170
Getting Started 171
Picking the Right Channel 173
Marshaling Data 174
Using a Separate Interface 175
Remoting Singletons 176
Security 177
Tying It All Together 178
Conclusion
183
6 Custom Network Communication
185
An Overview
of Network Communication 186
Network Architectures 186
Communications Protocols 188
The WebRequest
Class: More Than Meets the Eye 192
Supporting Client Authentication 194
Managing Your Connections 194
Creating Custom WebRequestModules 196
Advanced WebRequest Features 198
The WebClient
Class 203
Socket
Programming 206
Getting Started with Addressing 206
Using the TcpClient, TcpListener, and UdpClient Classes 208
Down to the Wire: Socket-Level Network Programming 212
Conclusion
218
7 Windows Services
219
Introduction
to Windows Services 220
The ServiceController
Class 222
The Service Manager Application 225
The Windows
Event Log 228
A Simple
Service 230
A Timely
Example of a Service 233
Communicating with the Service 234
Updating the Date and Time 238
Installing
a Service 244
Debugging
a Service 247
Debugging the OnStart Method 248
The Trace Class 249
Conclusion
250
8 Integrating Enterprise-Level
Services 251
Understanding
COM+ and Enterprise Services 251
COM+ Requirements 253
Creating a Serviced Component 253
Understanding Application Activation 256
Understanding COM+ Contexts 258
COM+ Object Construction 260
Object Pooling 262
Just-in-Time Activation 269
COM+ Transactions 272
Messaging
280
Messages 281
Message Queues 281
Messaging in Visual Basic .NET 283
Creating Your First Queue 284
Working with Your Queue 286
Automating Queue Installation 294
Conclusion
295
9 Adding Security to Your Applications
297
Security
Features in .NET 298
Role-Based Security 298
Web Application Security 299
Evidence-Based Security 299
Cryptography 301
Buffer Overrun Detection 305
Enterprise
Security Scenarios 305
Code Security 305
User Identity 310
Scripting Security 311
Authentication and Authorization 313
Conclusion
320
PART III PERFORMANCE
AND DEBUGGING
10 Essential Debugging Techniques
323
Debuggers
323
The Visual Studio .NET Debugger 324
Other Debuggers 325
Better
Debugging with the .NET Diagnostic Tools 330
The Debugger Class 330
Event Logs 331
The Trace and Debug Classes 341
Conclusion
350
11 Common Performance Issues
351
String
Concatenation 352
StringBuilder Makes the Grade 353
Format Strings 354
String Performance by the Numbers 356
Late
Binding 358
Designing
Types 360
Error
Handling 364
On Error Goto and On Error Resume Next vs. Exceptions 364
Exception Handling Best Practices 366
Database
Issues 366
Database Connection Leaks and Connection Pooling 366
Using a DataReader with a Stored Proc Whenever Possible 370
Using Ordinals Instead of Column Names 371
Resource
Management and IDisposable 373
ASP.NET
374
ASP.NET Session State 374
STA COM Interop in ASP.NET 374
Loading
the Right Runtime 377
Conclusion
382
12 The Art of Performance Tuning
383
Performance
Testing 383
Tools of the Trade 384
Performance Test Planning 391
Performance
Tuning 393
The Sanity Check 394
Attaching a Debugger 397
Low-Level Analysis 397
Conclusion
398
A Using Visual Basic .NET in
a Multideveloper Environment 399
Architecture
and Design Issues 399
Analyzing Business Requirements 400
Defining the Technical Architecture for a Project 400
Visual Studio .NET Enterprise Architect 401
Making
the Most of Visual Studio .NET 401
Modeling Tools 401
Enterprise Templates 402
Visual SourceSafe and Source Control 406
Managing Web Projects 409
Managing Dependencies 410
Customizing the Start Page 412
B Getting Started with Application
Center Test 415
An Overview
of ACT 416
Using the Standalone Version of ACT 417
Useful
Techniques for Customizing ACT Tests 421
Inserting Random Delay into Your Tests 421
Extracting ASP.NET ViewState from the Response Object 422
Appending ASP.NET ViewState to a Request 422
The ACT
Test Object Model 423
C Common Language Runtime Performance
Counters 427
.NET
Performance Counters 429
.NET CLR Data 429
.NET CLR Exceptions 429
.NET CLR Interop 431
.NET CLR JIT 431
.NET CLR Loading 432
.NET CLR LocksAndThreads 434
.NET CLR Memory 436
.NET CLR Networking 442
.NET CLR Remoting 442
.NET CLR Security 444
Performance
Counters for ASP.NET 445
ASP.NET Applications 447
D Performance Counter Quick Reference
453
Common
Performance Counters 453
Application-Specific
Counters 454
ASP.NET and Web Services 455
SQL Database Applications 456
Applications That Use Interop or Remoting 457
INDEX 459 |