The Book of Visual Studio

[Pages:100]The Book of Visual Studio .NET--A Guide for Developers

Robert B. Dunaway

NO STARCH PRESS

San Francisco

Copyright ? 2002 Robert B. Dunaway

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

1 2 3 4 5 6 7 8 9 10-05 04 03 02

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Publisher: William Pollock Editorial Director: Karol Jurado Cover and Interior Design: Octopod Studios Composition: 1106 Design, LLC Developmental Editor: William Pollock Copyeditor: Kenyon Brown Proofreader: Mei Levenson Indexer: Broccoli Information Management

Distributed to the book trade in the United States by Publishers Group West, 1700 Fourth Street, Berkeley, CA 94710; phone: 800-788-3123; fax: 510-658-1834.

Distributed to the book trade in Canada by Jacqueline Gross & Associates, Inc., One Atlantic Avenue, Suite 105, Toronto, Ontario M6K 3E7 Canada; phone: 416-531-6737; fax 416-5314259.

For information on translations or book distributors outside the United States and Canada, please contact No Starch Press, Inc. directly:

No Starch Press, Inc. 555 De Haro Street, Suite 250, San Francisco, CA 94107 phone: 415-863-9900; fax: 415-863-9950; info@;

The information in this book is distributed on an "As Is" basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

Library of Congress Cataloguing-in-Publication Data

Dunaway, Robert B. The book of Visual Studio .NET/Robert B. Dunaway. p. cm. Includes index.

1-886411-69-7

(pbk.)

1. Microsoft Visual Studio. 2. framework. 3. Web site development--Computer programs. I. Title. TK5105.8885.M57 D86 2002 005.2'76--dc21 2001030346

Dedication

To Tamarah: Your steadfast love has inspired me to become a better man. I love you.

To my Grandfather: The principles and love you have shown me remain. I miss you.

ACKNOWLEDGMENTS

This book is the product of a combined effort. My thanks to all involved at No Starch Press.

I would like to thank Bill Pollock for believing in me as a first time writer and for his patience throughout the writing of this book. Thank you for the countless hours you spent guiding and editing my work so that it would be more enjoyable and understandable to read.

Special thanks to Karol Jurado, the Editorial Director, for coordinating the entire effort and fielding my many questions. You've help make this an experience I would like to repeat.

I would also like to thank Ken Brown, the copyeditor, and Mei Levenson, our proofreader. I know that catching my grammatical errors is no trivial task.

Special thanks to William H. Bennethum, whose friendship, criticism, and encouragement means the world to me. Your comments and insight concerning this book have been invaluable.

Thanks to Cheryl and Jeffery Dunaway, for your love and for teaching me that nothing was out of my reach.

Thanks to Michael and Cathy Browning, for your guidance in my career and your continued support.

Special thanks to my Grandmother, Maude Jump, for your continued love and support.

Robert B. Dunaway Cincinnati, Ohio

Introduction: Introducing .NET

When designing the contents, format, and general layout of this book, the challenges that developers face when implementing Microsoft .NET technologies were considered. The .NET initiative offers both a new set of technologies and a new paradigm for development, because it is not only a development environment but also an entire suite of servers and services that work together to deliver solutions to solve today's business problems. The book could have perhaps more easily addressed a single vertical portion of the .NET suite of technologies, but then how would you know how or where that portion fits into .NET model, and how could you take advantage of other services that are provided by the vast set of .NET technologies? The truth is that you probably could not.

One book simply cannot adequately cover all of the technologies that are required to deliver a complete .NET solution. .NET encompasses several new technologies, including new versions and enhancements of nearly every current technology. These products include SQL Server, Windows XP, .NET Enterprise Server, and industry-standard technologies such as XML and SOAP.

This book provides you with a solid understanding of Visual Studio .NET and of how to use it to implement a variety of .NET solutions (a considerable challenge, given the number of technologies that make up the .NET framework). You'll focus mainly on Visual Studio 7 .NET, while still getting an overview of several .NET-related technologies. In fact, you'll get quite a bit more than a simple overview of Visual Studio .NET and related technologies; you'll learn exactly where each technology fits into the big picture of .NET, and you'll run sample code that demonstrates your ability to take advantage of that technology today! Good luck and enjoy.

Level of Expertise

The Book of Visual Studio .NET assumes that you are familiar with Windows-based programming, object-oriented programming, Windows 2000 Advanced Server, Windows XP, or .NET Enterprise Server. It will also be helpful for you to understand SQL Server, COM, and COM+ because they are required to build a scalable and reliable Windows DNA application. Knowing these technologies will make the transition to the .NET Framework easier for you to handle. While the book assumes this knowledge, it will discuss much of this technology throughout because of the way .NET integrates it to build business solutions. If you are lacking in any one of these areas, do not fear; you won't be by the time you finish this book.

Note While many of the examples are written in Visual Basic (VB), and the book has included a chapter on Visual Basic .NET, don't expect to learn Visual Basic .NET here. If you already know Visual Basic, you will be better able to take advantage of these code examples. If not, you will get an introduction to areas of Visual Basic .NET that you will need to explore in a book that is geared more toward learning the Visual Basic .NET language.

Who Should Read This Book?

This book is only a starting point for understanding the .NET suite of technologies, which is essential for any successful .NET delivery. Once you are finished with this book, you will be able to relate whatever you are doing to some portion of the .NET framework.

The Book of Visual Studio .NET is for intermediate and advanced developers who want to build scalable, reliable, flexible, and manageable systems using Visual Studio .NET. If you are a developer, an architect, or a manager of a software development team, this book is for you.

You will also find this book helpful if you aspire to become a software architect with an understanding of how the pieces of .NET technology fit together to form a business solution.

Finally, while every development manager does not need to understand the details of COM+/Enterprise Services, , , or SOAP/Web Services, an understanding of the issues that are involved in integrating multiple .NET technologies will enable you to better lead your team. You will be better prepared to deal with the complexities of the next wave of software development for both the Internet and the desktop.

Goals of This Book

This book does not take an exhaustive look at any one language or technology. While you will gain new insights into these technologies, you will not learn the technologies themselves.

You will, however, learn to use Visual Studio .NET to implement a variety of .NET technologies as we take an exhaustive look at the .NET Framework. The book covers many new and updated .NET tools (with tutorial-like examples of how to use them). As you learn, you will see, in great detail, the process of building compiled components has significantly changed compared to how classic COM has been implemented. The book also discusses how languages have been enhanced and DLLs changed. Finally, the book examines a variety of nuances introduced by .NET and Visual Studio .NET.

By the end of this book, you should have a firm grasp on what this new world of .NET development technology is all about. You will be able to answer the question, "What is .NET?" with confidence, and communicate the benefits of .NET. But more importantly, you will be able to use all of the .NET tools and implement other .NET technologies by using Visual Studio .NET.

Chapter 1: Why .NET

.NET, like any other technology, must be carefully evaluated before an educated decision can be made concerning its use. Before we continue discussing the values of .NET we will briefly look at how problems can be solved using .NET.

Business Problems Addressed by .NET

Many Internet solutions have been patterned after the mainframe's centralized model. New technologies in the PC world, such as transaction support and messaging, are mature technologies in the mainframe world, and in many ways, the mainframe has paved the way for the Internet. However, it is important to understand that the mainframe, while incorporating many technologies, leans toward centralization. In this chapter we will cover key architectural designs leading to today's application designs as they are implemented using .NET.

In many ways, the PC world itself has made a few paradigm shifts as it has moved from computing on separate, unconnected workstations to the PC network and a client/server relationship. Network file and print servers provided a way to share information and a single point of administration. The addition of file services turned the PC into an application server.

The birth of client/server computing helped to reduce the workload on the client PC and to increase performance and reliability. Rather than relying on the client application to manipulate and manage its own e-mail files, services ensures that the client's responsibilities are limited to requests and replies while the server does the work, thus improving reliability because the PC could no longer damage its own data in the event of a crash.

The first PC networks involved file and print servers with a centralized means of sharing information and a single point of administration, as shown in Figure 1-1. The server simply serves the files required to run an application. This is a client/server model only in the context of file and print services; the application itself isn't really a true client/server application, and it only takes advantage of certain client/server services that are needed to run the application from a central location.

Figure 1-1: This diagram represents the old client-controlled model.

The problems with this centralized computing model range from loss of performance to data corruption. Performance is slow because the client application must do all the work necessary to make the application functional, with the network as intermediary. Due to the ever-present risk of client instability, the potential for data corruption is also high. If the client fails while handling files on the file server, it can easily corrupt application or data files.

The true client/server model, shown in Figure 1-2, never allows the client to actually touch the application or data. The client has no impact on the application or data files, performance is improved, and the risk of data corruption by the client is significantly reduced. The server maintains the application data.

Figure 1-2: This diagram represents a client/server model. Today, a single server performs all Internet-related application services, from authentication to data access. This may not present many challenges on a small scale, but when the frequency of data access exceeds the database server's capabilities and the application server receives more requests than it can respond to, we have problems. And what about reliability? If any portion of this solution, which in many cases resides on a single server, is overwhelmed or crashes, the business solution fails, and the business depending on this solution may be damaged. Likewise, the client browser can have difficulty manipulating or intelligently handling data. The web browser is basically dumb and, for the most part, does what it's told, thus greatly reducing the browser's ability to meet an individual's specific needs. The .NET suite of technologies includes everything from development tools to Web Services in an effort to increase scalability, reliability, flexibility, and manageability, thus addressing these business issues. As such, .NET frees the web server from its limited communication with the client web browser, and allows it to communicate with other web servers on the client's behalf (see Figure 1-3). For instance, if you schedule a service to be provided by a business, like canceling or rescheduling a flight, and if that business is unable to fulfill your request, your provider's Web Services will work with other Web Services to find another provider to satisfy your needs.

Figure 1-3: A server working with other Web Services on behalf of the client.

Performance and Scalability

If a system is not scalable, there's not much point in building systems to support large numbers of concurrent users. In fact, when considering large systems, performance is important, but scalability is still more important.

Performance refers to the number of processor cycles that are necessary to complete any given task, or the time that is required to complete a single task. Scalability is the number of concurrent users that are able to perform a task at the same time. For example, say you run a component that returns information at an incredible rate. The cost of this transaction is 100 percent CPU utilization. While the performance of this task is good, its scalability is poor because the CPU can support only one or two concurrent users who are requesting this transaction.

Scalability is almost entirely determined by your application's architecture and adherence to good coding practice. Even one poorly written routine or transaction can reduce an application's performance. You'll learn about these topics and more in Chapter 2 in which tiered development is covered.

The Benefits of .NET

For the developer, the answer to the question "Why .NET?" revolves around the benefits of Visual Studio .NET and the meaning of ".NET."

.NET is a set of cross-platform technologies, including time-tested and accepted protocols, such as HTTP, and platform-independent standards like XML. These two technologies allow COM and CORBA to interoperate, through Web Services, like never before. Issues concerning the platform are now removed, so developers can concentrate on business requirements.

Note As we witnessed with the rise and fall of Windows DNA, Microsoft often changes the names of its new technology suites. .NET (pronounced "dot net") was first called NGWS, Next Generation Windows Services.

.NET is a moving target and is clearly in a state of flux. While much of what we know about .NET is not likely to change, new methodologies and paradigms are sure to arise that will add to what we already know and understand. And, as these new and innovative technologies emerge, some will fail to achieve industry acceptance and will be discarded or will simply disappear.

Before the Internet, most application development was limited to Windows-based forms. As the Internet's popularity rose, the development of web applications increased and the world began to change.

Early web technologies were limited to creating static pages with click-and-link functionality. This satisfied users initial web requirements because people were simply happy to be able to surf the Web and even more pleased to contribute to its growth. For the most part, this also satisfied the requirement of providing information to a growing Internet population. However, as businesses began building static websites, they realized quickly that consumers wanted more dynamic pages that would reflect new and changing products.

Acceptance of Open Standards

One of the most important aspects of .NET is Microsoft's acceptance of open industry standards. The full acceptance and implementation of XML is significant. While XML is not the "end all" technology that some people think it is, it's one of the few available ways to integrate disparate systems. Without an open standard like XML, developers would need to rely on proprietary third-party applications for data integration.

Nearly every one of Microsoft's current servers (see Table 1-1) will be a .NET server that supports XML and the .NET Framework. (Previous versions of SQL Server had very limited XML support.) The implementation of industry standard protocols in .NET and throughout Microsoft servers marks Microsoft's effort to create cross platform applications, as servicesnothing less than a paradigm shift for traditional Microsoft application developers.

Server

Table 1-1: Current and future .NET servers Description

Microsoft Application Center Server 2000 Microsoft BizTalk Server 2000

Microsoft Commerce Server 2000 Microsoft Exchange 2000 Microsoft Host Integration 2000 Microsoft Internet Security and Acceleration Server 2000 Microsoft SQL Server 2000

Manages clusters and deploys web applications.

Implements business processes and provides data through an agreed-upon interface. Helps in building e-Commerce applications. Enables messaging and collaboration (e-mail). Allows communication with the mainframe. Operates as a firewall and web cache.

Offers database storage and analysis services.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download