Home > Store

.NET Programming: A Practical Guide Using C#

Register your product to gain access to bonus material or receive a coupon.

.NET Programming: A Practical Guide Using C#


  • Sorry, this book is no longer in print.
Not for Sale



  • Knowledge for building enterprise-class .NET applications—Offers deep insight into the .NET architecture, Common Language Runtime, and Framework Class Library, plus a thorough working knowledge of how to put .NET's services to work.
    • Gives students all the information and insight they need to begin building enterprise-class .NET applications as rapidly as possible.

  • Full project lifecycle coverage—Covers development, packaging, deployment, and maintenance from the perspective of the working developer.
    • Helps students play any role on a .NET development team, while also understanding the big picture.

  • Extensive C# programming examples in the book and ftp site—Contains thoroughly-annotated example code that illuminates each of .NET features covered in this book.
    • Enables students to learn from real code—the most effective way for most students to learn programming.

  • .NET internals and services—Illuminates the internals of the .NET Framework and demonstrates how to take full advantage of its services.
    • Helps students leverage the full power of the .NET platform.

  • Detailed coverage of interoperability with legacy Windows applications—Presents in-depth coverage of interoperability with both native DLLs and COM applications.
    • Helps students integrate new .NET software into existing IT environments.

  • Advanced .NET distributed computing techniques—Offers start-to-finish guidance on developing object-remoting applications for intranets, and Web services for the Internet.
    • Helps students build the types of applications that are increasingly demanded by the marketplace.

  • Techniques for securing .NET applications—Explains how to develop secure applications using role-based security, and then enforce security for third-party applications using code access permissions.
    • Gives students practical tools for securing .NET distributed applications against malicious code or unauthorized intrusions.

  • Advanced techniques for writing thread-safe code—Demonstrates how to develop thread-safe code using the .NET synchronization infrastructure, and offers new insight into asynchronous programming.
    • Helps students build more responsive applications.

  • Detailed coverage of transactions—Illuminates the complex issues traditionally involved in supporting transactions and shows how the .NET platform simplifies this.
    • Gives students practical solutions for maintaining the integrity of data across multiple applications and machines in distributed computing environments.

  • Comprehensive coverage of scalability—Reviews all .NET mechanisms for improving scalability in enterprise applications.
    • Helps students build applications that can grow smoothly to meet increasing demands.

  • Reflection and its applications—Introduces reflection, one of .NET's most powerful features—and shows developers how to take full advantage of it.
    • Gives students an in-depth understanding of one of .NET's most sophisticated tools for building powerful, flexible applications.


  • Copyright 2003
  • Dimensions: 7" x 9-1/4"
  • Pages: 496
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-066945-8
  • ISBN-13: 978-0-13-066945-2

This hands-on, example-rich guide to .NET has two goals: to help you gain an in-depth understanding of .NET's architecture, and to use .NET's services to start building enterprise-class applications as quickly as possible. Pradeep Tapadiya begins by establishing a solid foundation for enterprise .NET programming. He reviews Microsoft's short and long-term goals for .NET, illuminates .NET's programming model and infrastructure, and walks through the entire process of building a .NET application, from development through deployment and maintenance. Next, he presents in-depth coverage of .NET's support for distributed computing and Web services; and its approach to interoperability with COM and non-COM-based legacy applications. Detailed chapters address concurrency and multithreading; new .NET server and client security issues; transaction processing; .NET mechanisms for optimizing scalability; and the effective use of reflection and assemblies. An accompanying CD-ROM contains all of the book's extensive source code. For all developers and project managers working with Microsoft technologies, and for every IT professional who wants a practical understanding of .NET.


Source Code

Untitled Document Download the Source Code file related to this title.


Author's Site

Untitled Document

Visit the Author's Web Site related to this title.

Sample Content

Online Sample Chapter

.NET Programming: What Is .NET?

Downloadable Sample Chapter

Untitled Document Download the Sample Chapter related to this title.

Table of Contents




1. What Is.NET?

Introduction. The Vision. The Platform. The.NET Framework. Development Tools. Foundation Services. What Does It All Mean? References.

2. From C++ to C#.

A Simple “Hello User” Program. C# for C++ Programmers. Common Programming Paradigms. Deployment. Diagnostics and Support. Summary. References.

3. Assemblies.

Assemblies. Assembly Identification. Anatomy of an Assembly. Shared Assemblies. Configuration Files. Assembly Binding. Attribute-Based Programming. Advanced Topics. Summary. References.

4. Essentials of the .NET Framework.

.NET Framework Overview. Configuration. Common Language Runtime. Microsoft Intermediate Language. Managed Code Execution. Automatic Memory Management. Hosting the Runtime. Summary. References.

5. Programming with the Base Class Library.

Enumeration. Collection. Cloning. Streams. Serialization. Strings. Summary. Reference.


6. Distributed Computing.

Application Domains. Contexts. Marshaling. Remoting Architecture. ASP.NET Web Services. Remoting Internals. Summary. References.

7. Interoperability.

Introduction. Managed Code to Native DLLs. Accessing COM Components from .NET. Accessing .NET Components from COM. Summary. References.

8. Concurrency.

Multithread Programming. Multithreading Issues. Asynchronous Programming. Summary.

9. Security.

Introduction. Code Access Security. Role-Based Security. ASP.NET Web Services Security. Summary. References.

10. Enterprise Services.

Enterprise Systems: .NET and COM+. Developing.NET Serviced Components. JIT Activation. Object Pooling. Role-Based Security. Queued Components. Transactions. Summary. References.




Computing lifestyles and development needs change with time. Over the years, a number of paradigms and programming methodologies have been offered to support the needs of the developers and software vendors.

In the mid 1990s we saw monolithic applications being broken into smaller applications that communicated with each other. To facilitate code reusability and application communication across compiler boundaries and programming language boundaries, Microsoft introduced a framework called Component Object Model (COM). To further facilitate the communication across machine boundaries, Microsoft extended the model to Distributed COM (DCOM).

The late 1990s witnessed an incredible explosion of the Internet that caused a revolution in the way information was made available to the users. In developing enterprise systems, the traditional client/server model was replaced by a three-tier programming model, enhanced for Internet applications. Developing such enterprise systems was a time- and resource-consuming affair, as the systems had to meet extra enterprise-level requirements such as scalability, robustness, security, transaction support, and so on. To help developers meet these challenges, Microsoft introduced COM+, an advanced runtime environment that ran on Microsoft Windows 2000. Developers could now leverage the services provided by COM+ instead of building the services themselves.

In the new millennium, the Internet is evolving from a collection of isolated Web sites and applications into a general "communication bus" for distributed applications that can run on various hardware and operation system (OS) platforms.

Microsoft's .NET platform is based around this vision.

As part of the .NET initiative, Microsoft has provided a framework and some tools that developers can use to build applications targeting .NET platform.

Although .NET achieves many of the same goals that COM does, make no mistake—.NET is a radically new platform. The programming model has been an evolution over COM, but the framework implementation is completely different. However, the enterprise system needs (e.g., scalability, transaction support, etc.) haven't changed much. Therefore, many COM+ services have found their way into .NET.

This book focuses on understanding .NET architecture from a developer's perspective and building .NET applications primarily using C#, a new programming language that offers the flexibility of C++ and the simplicity of Visual Basic.

About This Book

The purpose of writing this book is twofold:

  1. To help you understand .NET architecture in detail.
  2. To explore the services provided by the .NET Framework in building enterprise-level applications.

To achieve the first goal, a hands-on approach is employed in this book. As we progress through unfolding .NET technology, I present a key concept, accompanied by code samples as necessary.

The second goal is to use .NET productively in building enterprise-level applications. Enterprise-level requirements include security, transaction support, scalability, dealing with concurrency, distributed three-tier computing, dealing with legacy code, and so on. This book seeks to do the following:

  • Provide an in-depth analysis of all aspects of .NET technologies related to enterprise-level application development.
  • Provide ideas to develop robust .NET applications.
  • Provide programming code to achieve common .NET programming tasks.
  • Provide concise, complete sample programs to illustrate the concepts presented.

I have tried to present the material such that it makes interesting reading for developers. Not only can developers gain an in-depth knowledge of .NET platform, but they can also get familiar with programming in other related technologies such as SOAP, XML, ADO.NET, and ASP.NET.

The book starts with an overview of .NET platform from a nontechnical perspective. Then I progress through unfolding the .NET architecture and services. Wherever applicable, code samples are provided to illustrate and explain the concepts. This book provides enough sample code to enable readers to be more productive and to carry out further research.

Intended Audience

The intended audience includes the following groups:

  • Software developers and engineers who are involved in developing software products for the Windows platform and typically use C++ or Visual Basic as their programming language.
  • Managers who actively supervise a software product.
  • Computer science students. Today, more and more companies expect job candidates to understand COM and COM+ technologies. Senior students and graduate students are becoming more aware of COM technology as a software engineering discipline. The next logical step for them would be to start programming in .NET.

Choice of Programming Language

A vast majority of the .NET programming community will be using C# for developing .NET applications. As a matter of fact, a large part of the .NET Framework has been developed in C#. Hence, I chose C# to present samples in most cases. However, in some instances I have used Visual Basic.NET or another language that is appropriate for the given situation.


The most important prerequisite for this book is a willingness to learn.

The book is written for intermediate to advanced developers. It is assumed that readers have a working knowledge of the following:

  • C++ or Java programming languages.
  • Windows 2000 operating system.

Note that knowledge of C# is helpful but not mandatory, as long as you are familiar with C++ or Java. As we go through developing sample code, I am confident readers will automatically pick up adequate information about the language.

Sample Code

All the examples provided in the book are concise and complete. For brevity, I sometimes show only the relevant code sample in the book. However, complete source code is available on the companion Web site (www.phptr.com/tapadiya/dotnet/). All the examples and tools have been compiled with Microsoft Visual C# 1.0 and the .NET Framework Software Development Kit (SDK), and have been tested on Windows 2000 SP2 and Windows XP.

The samples are organized by chapters. Each sample is built as a separate project. A project can be compiled either from Visual Studio .NET or from the command-line makefile. The makefile can be found in the bin directory under each project, except for Chapter 2. In order to illustrate some key compiler concepts, Chapter 2 contains the makefile in the same directory as the project.

Note that Visual Studio .NET requires that a project belongs to a solution. The project file has an extension .csproj and the solution file has an extension .sln.

In order to build the projects from the command line, you need to set up proper paths in the environment. If you have installed Visual Studio .NET, then you can use the command-line link that is provides called the "Visual Studio .NET Command Prompt." This link initializes the environment for the command window such that the .NET Framework SDK tools can be accessed from the command line.


This book frequently refers to other books, Microsoft's Knowledge Base articles, articles from various journals, and Microsoft's Developers Network (MSDN) Library. All the references for a particular chapter are listed at the end of that chapter. Each reference entry is indexed by a keyword that uses a combination of author's last name and year the reference was published. For example, Don Box's book Essential COM, which was published in 1998, is indexed as Box-98. In the book, each time I cite a reference, I use the relevant keyword.

Chapter Organization

The book is divided into two parts. The first part, Chapters 1-5, focuses on the fundamentals of .NET Programming Model and shows how to develop .NET-based applications.

The second part, Chapters 6-10, focuses on the services provided by .NET. Each chapter focuses on a specific aspect of .NET. These chapters are largely independent of each other.

Chapter 1: What is .NET?

.NET is Microsoft's new initiative for building applications regardless of the platforms or languages in use. The .NET label applies to three distinct but related items: a vision for how information technology (IT) will evolve, a software platform to build .NET applications, and an application-hosting business designed to support the vision and market the platform. In this chapter, we inspect each of these items from a fairly nontechnical perspective. By the end of the chapter, the readers will have a good idea of where Microsoft is going with the .NET initiative and will understand the terminology, features, and services offered by the .NET Framework, the software platform for .NET applications.

Chapter 2: From C++ to C#

This chapter focuses on various stages of building .NET applications-from development to debugging and deploying. You will write simple C# programs to explore common programming paradigms under the .NET Framework. In the process, you will learn the differences and similarities between C++ and C#. By the end of the chapter, readers will understand many key concepts of the .NET Framework and will be fairly comfortable developing simple .NET applications using C#.

Chapter 3: Assemblies

Under .NET, assemblies form the fundamental building block of program components. In defining the format for the assembly, .NET had many goals. These goals included interoperability among different programming languages, side-by-side execution of multiple versions of the same assembly, performance enhancements, and so on. In this chapter, we take an in-depth look at the assemblies and examine how these goals were achieved. By the end of the chapter, you will have a good knowledge of the assembly internals and the packaging and deployment model under .NET.

Chapter 4: Essentials of the .NET Framework

In this chapter, we examine the facilities that the .NET Framework provides to load and execute the code and provide services to the executing code. We start with an overview of various components that constitute the .NET Framework. Then we look at the overall process of managed code execution. We will see how .NET applications can be administratively controlled using external configuration files and how the configuration mechanism can be extended to store custom settings. We then look at the type system used by the common language runtime and examine the memory and performance considerations of using reference types versus value types. We examine how the CLS provides for cross-language interoperability. We look at how the execution engine validates the metadata, verifies the MSIL code for type-safety, and performs JIT compilation on the MSIL code. Finally, we look at the automatic memory management features of the runtime and how it simplifies or complicates programming under .NET. By the end of the chapter, you will have a good understanding of .NET architecture and how it helps in producing robust applications that can potentially be reused by any programming language under .NET. You will also learn the strategies of generating efficient code.

Chapter 5: Programming with the Base Class Library

The .NET BCL includes hundreds of classes that provide a number of useful services to help developers boost their productivity. In this chapter, we look at how to solve many common programming tasks using these classes. By the end of the chapter, you will become familiar with many important classes under the .NET Framework.

Chapter 6: Distributed Computing

In this chapter, we look at how to develop distributed applications under .NET that can communicate within intranets as well as over the Internet. We will see how .NET remoting offers seamless remote activation and remote method calls, among other things. We examine how to develop intranet applications using this support. Over the Internet, Web services have become the building blocks for distributed Web-based applications. We will look at the support offered by ASP.NET to create and deploy Web services. By the end of this chapter, readers will be comfortable developing applications using the common language runtime object-remoting and will be fairly conversant with ASP.NET Web services development.

Chapter 7: Interoperability

The .NET Framework provides support for managed code to interoperate with unmanaged code. The unmanaged code could either be COM-based or be in native DLLs. The .NET Framework has been designed to provide smooth interoperability. In this chapter, we examine the support for interoperability provided by the .NET Framework. By the end of the chapter, readers will be comfortable making calls from managed code into unmanaged code and vice versa.

Chapter 8: Concurrency

Under Windows, and most other modern OSs, a process can execute multiple threads concurrently, each of which carry out a specific task. The .NET Framework supports developing multithreaded applications in two ways-by supporting the creation and use of threads and by providing a mechanism to make asynchronous calls. In this chapter, we examine both these techniques in detail. We also look at various issues involved with multithread programming and the support provided by the .NET Framework in developing classes that are safe from concurrent access.

Chapter 9: Security

The .NET Framework offers two security mechanisms-code access security and role-based security. Both security mechanisms are built on top of the security provided by the underlying OS. Code access security keeps track of where the assemblies come from and what security permissions should be granted to them. Role-based security enables the code to make security decisions based on the role of the user executing the code.

In this chapter, we look at the concepts underlying code access security and role-based security. We also examine the classes and services provided by the .NET Framework to facilitate the use of these security mechanisms.

Security is also an important consideration for ASP.NET applications. ASP.NET applications need to authenticate clients and provide restricted access to any sensitive data, based on the client credentials. In addition, the ASP.NET applications may also have to act on behalf of the client in some cases to access OS secured resources such as NTFS files. In this chapter, we also examine various security features that ASP.NET provides to deal with authentication, authorization, and impersonation.

Chapter 10: Enterprise Services

Enterprise system development has historically been a very time- and resource-consuming process. The development complexity arises from the extra enterprise-level requirements such as scalability, robustness, security, automatic transaction processing, and so on.

The .NET Framework provides many infrastructural services to meet the needs of enterprise systems. This allows businesses to focus on their core competencies instead of building the plumbing themselves.

In this chapter, we examine in detail some important requirements for enterprise systems and the services provided by .NET to meet these requirements.

Companion Web Site

The companion Web site (www.phptr.com/tapadiya/dotnet/) contains the source code for all the examples in the book, arranged by chapters. For the most up-to-date information, see the read-me file at the Web site.

Author Biography

Pradeep Tapadiya is a lead software architect at the OpenView R&D Division of Hewlett-Packard in Roseville, CA and has been working with Microsoft enterprise development technologies since 1996. He holds a doctoral degree in Computer Science from Texas A&M University. Tapadiya is also the author of COM+ Programming: A Practical Guide Using Visual C++ and ATL. Tapadiya can be reached at pradeep@tapadiya.net


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020