As the title suggests, this book is written for programmers who want to learn about the Microsoft .NET platform. There is a lot to learn. .NET development embraces many areas including:
In addition, programmers need to become familiar with an extensive new class library and a new runtime environment. Even for seasoned Windows developers, this almost amounts to a fresh start.
The purpose of this book is to explore the many parts that make up .NET, to assemble them into a meaningful whole, and to do so within the confines of a compact and readable publication. Although many of the topics we?ll explore, such as XML Web services, Windows Forms, or ADO.NET, are worthy of separate books in their own right, all are just pieces of the .NET jigsaw puzzle. I felt there was a need to examine each of the individual pieces, and to show how they relate to one another, and how they fit together. This book is the result.
The scope and size of .NET make it impossible to cover everything in a single book. So I?ve taken some shortcuts. In particular, I?ve tried to impart the essentials while avoiding unnecessary handholding, repetition, or padding. In general, the documentation, online help, and samples, which come with the .NET software development kit (SDK), are comprehensive and complete. So, armed with the knowledge gleaned from this book, you should be able to consult the documentation for supplementary information.
This book is written for intermediate and advanced programmers who plan to develop applications, components, or services for .NET. The typical reader will have some experience programming with Visual Basic, C++, or Java. This is not an absolute requirement, since I?ve included an appendix which provides an introduction to C#, the language used for the examples in the book.
To get the most out of chapter 4, ?Working with ADO.NET and databases,? you should have some knowledge of SQL database objects including databases, tables, and SQL queries. Likewise, chapter 8, ?Creating the Web Forms user interface,? assumes a basic understanding of the Web including HTML, HTTP, and forms processing.
.NET is a language-neutral platform, and comes with a huge set of class libraries that are accessible to all .NET-compliant languages. Therefore, you can code equally powerful programs using C#, Visual Basic .NET, JScript .NET, or a host of third-party languages. So which language should you choose?
The obvious candidates are C# and Visual Basic .NET since most Windows developers will be coming from a Visual C++ or Visual Basic background. At the outset, I considered including examples using both C# and Visual Basic .NET. However, it quickly became clear that the result would be a repetitious book, which might shortchange both groups of readers. I settled on C# since it was designed for use with .NET and carries no legacy baggage. Being designed with .NET in mind, it could also be argued that C# provides the most natural fit to .NET?s object model.
It is worth noting that there is less difference between C# and Visual Basic .NET than you might think at first glance. Programmers from both camps will need to get comfortable with assemblies, namespaces, types, classes, structs, enums, interfaces, methods, properties, events, delegates, threads, and more. These are features of .NET, and not the preserve of a particular programming language. So the differences between C# and Visual Basic .NET are mostly syntax-related.
Ultimately, you?ll choose the language(s) with which you are most comfortable. This book teaches .NET, not C#. I hope that, by placing the C# introduction in a separate appendix, it will help to distinguish the C# language from the (language-neutral) .NET platform.
Depending on the level of interest, I hope to be able to provide a Visual Basic .NET edition of this book in the future. Stay tuned.
Visual Studio .NET is Microsoft?s integrated development environment (IDE) for .NET programming. It provides an impressive array of features that automate many tedious development tasks, making your job easier. However, for the beginning .NET programmer, this automation hinders understanding. So we?ll build our examples, and our case study, using the .NET SDK tools.
Although you don?t need a copy of Visual Studio .NET to follow along, we won?t completely ignore the IDE. In particular, we?ll briefly explore the creation of Visual Studio .NET projects and the use of the drag-and-drop forms designer to create both Windows Forms and Web Forms.
This book contains eight chapters and three appendixes:
Chapter 1 provides an overview of the .NET architecture and introduces application development using the .NET Framework class library.
In chapter 2, we look at fundamental .NET features including types, assemblies, and the Microsoft Intermediate Language, or IL. Also, to illustrate reflection, we develop a simple language compiler.
The video poker case study is introduced and described in chapter 3. We develop simple COM-based and Internet Explorer-based versions of the game.
Chapter 4 introduces ADO.NET and the new disconnected architecture for data access via the Internet. We also look at XML serialization, and we implement a data tier for the case study.
In chapter 5, we explore the .NET remoting architecture and the activation models it offers. We also look at Windows Services and Microsoft Message Queuing, and we use what we learn to develop several new versions of the case study.
Chapter 6 describes .NET?s features for developing XML Web services. We look at SOAP, WSDL, and UDDI, and we present a Web service-based implementation of the case study.
We explore Windows Forms, the new class library for the creation of Windows GUI applications, in chapter 7. We examine the Windows Forms programming model, and we see how to design a GUI using the Visual Studio .NET forms designer. We also implement a Windows Forms-based version of the case study.
Chapter 8 explores ASP.NET and the Web Forms classes for the creation of browser-based applications. We examine the new server controls and we learn how to create our own user controls. We also look at designing Web Forms inside Visual Studio .NET, and we develop a Web Forms-based version of the case study.
Appendix A provides an introduction to the C# programming language. For readers who have no exposure to C#, this material provides all you need to follow the book?s examples.
Appendix B contains the C# code for the classes that make up the Poker.dll assembly.
Appendix C presents the C# listing of the Windows Forms-based video poker machine.
Each chapter builds on previous material. So the chapters are best read in the order presented.
This book contains many short programs and code snippets designed to illustrate .NET programming. While writing the book I?ve had several discussions about so-called real-life examples and I?ve had reason to think about this. Witness the increasing number of programming books that use e-commerce as a vehicle for examples. I generally dislike this trend for the following reasons.
The obvious problem with real-life examples is that people?s lives differ. The reader engaged in retail e-commerce may want to see an online shopping cart example. The banker might want to see a financial application. The list goes on.
The second problem is that real-life examples often deviate from established principles of good teaching. In general, an example should be just big enough to illustrate the point. Any bigger, and it can obscure it. This is particularly relevant for a new technology such as .NET. If you can demonstrate .NET remoting by invoking a method that says ?Hello from Server X?, then there is no need to distract the reader with details of an imaginary banking application.
However, there is no doubt that more substantial real-life examples can be useful, provided they are confined to a case study where they do not interfere with the presentation of basic concepts. Therefore, this book includes both short illustrative examples, and a complete case study. The case study provides a realistic example of a production .NET system consisting of several interrelated applications and components. For the most part, when introducing a concept for the first time, I use examples that are as short as possible. When we are acquainted with the concept, we apply what we?ve learned by integrating the feature into the case study.
The source code for all examples in this book is available for download from http://www.manning.com/grimes.
The case study is an implementation of a video poker gaming machine. I think it makes a good case study for the following reasons:
Is this a real-life example? Yes. For a short period in the mid-1980s I made a meager living writing video poker machine software. For those of you who are interested, the game was coded in PL/M-80, an Intel language for its 8080 series processors. The software was compiled on an Intellec development system and transferred directly to EPROM for testing inside the machine. (We didn?t have an in-circuit emulator.)
Any similarity between the game presented here and any commercial video poker machine, living or dead, is purely coincidental. In particular, the payout control strategy we explore is designed to illustrate ADO.NET database programming. It is not intended to be a serious payout management algorithm.
Once we?ve established the basics and introduced the case study in the early chapters, the typical structure of the each chapter is:
Therefore, the case study is a recurring theme throughout the book, and serves as a vehicle to implement what we?ve learned as we progress through the material.
The following typographic conventions are used in this book: