Home > Store > Programming > Windows Programming

Enterprise Services with the .NET Framework: Developing Distributed Business Solutions with .NET Enterprise Services

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

Enterprise Services with the .NET Framework: Developing Distributed Business Solutions with .NET Enterprise Services

Book

  • Your Price: $47.99
  • List Price: $59.99
  • Usually ships in 24 hours.

About

Features

The only book to clearly explain what .NET Enterprise Services are and how to use them to build effective scaleable business applications

° The first book in English to cover .NET Enterprise Services, a key new technology from Microsoft

° Learn how to build scalable business applications quickly and more easily

° Discover how to integrate .NET components with existing COM-based applications

° Author is a respected and visible member of the .NET Development community.

Description

  • Copyright 2005
  • Dimensions: 7x9-1/4
  • Pages: 576
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-24673-X
  • ISBN-13: 978-0-321-24673-8

"For anyone involved in the .NET community, it's hard to not have heard of Christian Nagel. Christian is a true heavyweight of .NET in general, and Enterprise Services in particular. By taking a relatively trivial application and architecting it in a way that would allow it to scale without any rework, users will find that using the techniques employed in this book will be of benefit to virtually any company that is running distributed or enterprise applications."

—William G. Ryan, Microsoft MVP, Senior Software Developer, TiBA Soutions, LLC

"Whether you are a seasoned architect or a new developer, distributed application development can be difficult, since it covers such a wide range of complex technologies. Until now there was precious little in the way of guidance—let alone a consolidated reference. Christian has provided that reference and more—going from the individual technologies to the big picture on how to architect and develop scalable distributed applications. Technical goodness through and through!"

—Clayton Burt, Managing Partner, Onzo, LLC

"Making the transition to distributed application architecture introduces many issues in security and deployment and requires a new way of thinking about events, transactions, and messaging. This book shows developers and architects alike how to use .NET Enterprise Services to create robust, secure, and maintainable applications in a distributed environment. This book is an excellent guide to the sometimes overwhelming field of .NET Enterprise Services."

—Brian Davis, Director of Software Development, InfoPro Group, Inc., Co-Creator, KnowDotNet.com

Enterprise Services with the .NET Framework is the only book that experienced .NET developers need to learn how to write distributed, service-oriented applications. Filled with clear examples in C# (with Visual Basic .NET examples available on the Web), this book will quickly get you up to speed on building distributed applications with serviced components. You'll also learn about Indigo, Microsoft's next-generation technology for building distributed applications, and how it compares to Enterprise Services.

Microsoft Regional Director, MVP, and veteran author Christian Nagel introduces and clearly explains the four major services included in Enterprise Services: Automatic Transactions, Queued Components, Loosely Coupled Events, and Role-Based Security. From his in-depth coverage, you'll learn

  • How to create a serviced component, how serviced objects are activated, and how to use the different kinds of object contexts

  • How to manage concurrency and synchronization for serviced components to achieve optimal performance and data integrity

  • How to integrate COM components with the .NET Framework

  • How to use serviced components over a network with DCOM, SOAP Services, and ASP.NET Web services

  • How to use .NET Enterprise Services transactions to achieve Atomicity, Consistency, Isolation, and Durability

  • How to build a compensating resource manager to allow your own resources to participate in Enterprise Services transactions

  • How to maintain application state in a client application, in a serviced component, in shared properties, or in a database

  • How to create and use Loosely Coupled Events using COM+

  • How to secure a distributed solution using authorization, authentication, impersonation, and confidentiality

  • How to deploy and configure Enterprise Services applications


© Copyright Pearson Education. All rights reserved.

Sample Content

Online Sample Chapter

Enterprise Services with the .NET Framework: Transaction Services

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents

    About the Author

    Foreword

    Preface

    Acknowledgments

1. Introducing .NET Enterprise Services.

    Building Applications

      Application Layers

      Logical Tiers and Physical Systems

      Clustering Solutions

      Service-Oriented Architecture

      Smart Clients

    The History of Application Services

      COM and .NET

      Microsoft Transaction Server

      COM+ 1.0

    .NET Enterprise Services

      Applications and Components

      Declarative Programming

      Catalog

      Administration

    Application Services

      Automatic Transactions

      Queued Components

      Loosely Coupled Events

      Role-Based Security

      New Features with COM+ 1.5

    Summary

2. Object Activation and Contexts.

    Contexts

      .NET Remoting Contexts

      Contexts with Serviced Components

      Mixing .NET and COM+ Contexts

    Creating a Serviced Component

      Assembly Attributes

      Signing the Assembly

      Global Assembly Cache

      Using Interfaces

      ServicedComponent Class

      Component Registration

    Client Applications

    Debugging

      Library Applications

      Server Applications

    Object Activation

      Construction Strings

      Just-in-Time Activation (JITA)

      JITA and Object Disposing

      Object Pooling

      Private Components

    Application Activation

    Summary

3. Concurrency.

    Synchronization Overview

      Using Locks

      Interlocked Class

      More Synchronization Options

    Apartments

      Single-Threaded Apartments

      Multithreaded Apartments

      Thread-Neutral Apartments

    .NET Enterprise Services Synchronization

      Activity

      Configuring Synchronization

      Synchronization Example

      Reentrancy

      Selecting the Synchronization Option

    Services Without Components

      ServiceDomain Class

      ServiceConfig Class

      Activity Class

      Using a New Activity

      Starting a New Context

    Summary

4. COM Interop.

    .NET Clients Without COM Interop

      Side-by-Side Support

    COM Interoperability

      COM Callable Wrappers and Runtime Callable Wrappers

      Default COM Configuration

      Generated Type Library

    COM Interface Types

      Custom Interfaces

      Dispatch Interfaces

      Dual Interfaces

      ComVisible Attribute

    Versioning

      Applications

      Components

      Interfaces

      COMCompatibleVersion Attribute

    Finding Assemblies

      Private and Shared Assemblies

      COM Registry Entries

      COM and .NET Requirements

    Visual Basic 6 Clients

    C++ COM Clients

    Scripting Clients

    Calling a COM Object

      C++ Component

      Runtime Callable Wrapper

      .NET Component

      Registration

      Client Application

    Summary

5. Networking.

    DCOM

      DCOM Transport Protocols

      Application Proxies

      Creating an Application Proxy

      Installing the Application Proxy

      Creating a DCOM Client Application

    SOAP Services

      .NET Remoting Overview

      Creating a Serviced Component Using .NET Remoting

      Configuring the Server Application

      Creating a .NET Remoting Client

      Disadvantages of SOAP Services

    Web Services

      Overview

      Implementing a Web Service with ASP.NET

      Creating a Proxy

    Summary

6. Data Access.

    ADO.NET Overview

    Sample Database

    Entity Classes

    Database Access

      Database Query

      Insert

      Update

      Calling Stored Procedures

    Datasets

      Filling Datasets

      Updating Datasets

    Summary

7. Transaction Services.

    Transaction Overview

      ACID Properties

      Distributed Transactions

    Programmatic Transactions

    Automatic Transactions

      Transaction Attributes

      Transaction Streams

      Transaction Outcomes

      ContextUtil Methods

      Automatic Transaction Example

      Setting the Transactional Vote

      AutoComplete Attribute

      Distributed Transactions

    Transactions with Services Without Components

    Transactions Support with ASP.NET

    Transaction Isolation

      Potential Transaction Isolation Problems

      Transaction Isolation Levels

    Monitoring the DTC

    Transactions with .NET 2.0

    Summary

8. Compensating Resource Management.

    CRM Architecture

    CRM Application Classes

    CRM Application Example

      Application Configuration

      Helper Classes

      Worker Components

      Compensator Components

      Client Applications

    Monitoring

    Summary

9. State Management.

    State Characteristics

    Stateful or Stateless Components

    Databases and Files

      Isolated Storage

      Active Directory

    Shared Property Manager

      Shared Property Group Manager

      Shared Property Group

      Shared Property

      Client Application

      SPM State Characteristics

    ASP.NET State Management

      Session

      Cache

      Accessing ASP.NET State from Within Serviced Components

      ASP.NET State Characteristics

    Client State Management

      SOAP Headers

      .NET Remoting Call Contexts

    Summary

10. Queued Components.

    Overview

    Product Versions

      Message Queuing Server

      Message Queuing Client

    Message Queuing Features

      Message Queues

      Messages

      Administration Tools

    Creating a Queued Component

      Assembly Attributes

      Interface Definition

      The CourseControl Class

      Registration

    Client

    Error Handling

    Transactional Queues

    Returning Data

    Summary

11. Loosely Coupled Events.

    LCE Overview

      Event Class

      Publishers

      Subscribers

      Filters

    Programming LCEs

      Event Class

      Publisher

      Persistent Subscriber

      Transient Subscriber

    Filters

      Subscriber Filters

      Publisher Filters

    Using LCEs Across the Network

      LCE Routing

      Event Class Proxies

    LCE and Queued Components

      Event Classes as Queued Components

      Subscribers as Queued Components

    Summary

12. Security.

    Security Overview

      Windows Security

      SQL Server

      Internet Information Server

      ASP.NET Web Applications

      ASP.NET Web Services

      Enterprise Services

    Identity

    Authorization

      Enabling Access Checks

      Defining Roles

      Defining Role Access

      Checking Roles Within Methods

    Authentication Levels and Impersonation

      Authentication Levels

      Impersonation

      Reading the Identity of the Caller

    Enterprise Services and .NET Remoting

    Summary

13. Deployment and Configuration.

    Deployment

      Automatic Deployment

      Manual Deployment

      Creating a Custom Installer

      Creating an Installation Package

    Attributes

    Admin Components

      Configuring the Application as a Service

    Summary

14. The Future of Distributed Applications.

    Web Services Specifications

      Network Communication

      Reliable Messaging

      Transactions

      Security

    Indigo

      Hosting Environments

      System Services

      Connector

      Service Model

      Messaging Services

    Moving from Enterprise Services to Indigo

    Summary

15. Case Study.

    Use Case-Course Management

    Sample Projects

    CourseManagement.Entities-Entity Classes

    The CourseManagement Database

    CourseManagement.Data-Data Access

    CourseManagement.Control-Serviced Components

    CourseManager-Windows Forms Client

    CourseRegistrationService-Web Services

    CourseRegistrationWeb-Web Application

    CourseRegistration-Queued Component

    Summary

Final Thoughts.

Further Reading.

Index.

Preface

Preface

This book is the result of many years of work. I started developing distributed business solutions on Microsoft platforms when the Microsoft Transaction Server was released in 1996. Since then I have worked on several projects helping customers with the design and implementation of business solutions. I have been asked to do many things—such as integrating existing technologies and creating custom frameworks that can be extended in a flexible way for certain applications.

When Microsoft showed a preview version of .NET at the Professional Developers Conference in 2000 I was really excited about this new technology. Since then I've co-authored many .NET books, including Professional C# (Wrox 2004), Beginning Visual C# (Wrox 2002), C# Web Services (Wrox 2001), and Prof .NET Network Programming (Apress 2004).

Many of the things I've learned over the years have been combined to form this book.

Why would you use .NET Enterprise Services? .NET Enterprise Services is the .NET way to use COM+ Services, a technology that is part of the operating system and is used by companies throughout the world. .NET Enterprise Services extends COM+ Services with .NET behavior to make use of this technology. Regardless of whether you use Windows Forms or ASP.NET to create business solutions that have front-end applications, on the server side common features are needed for building scalable and interoperable solutions.

With .NET Enterprise Services you get features such as resource management with object pooling and thread pooling, automatic and distributed transactions, a lose connection between the server and the client for performing callbacks, queued components that can be used as an abstraction layer for message queuing, role-based security, and much more.

Who Should Read this Book?

This book isn't an introduction to .NET programming; there are many other books that fill that role. With this book I assume you already have some knowledge of .NET programming.

Although COM+ is the base of .NET Enterprise Services, COM knowledge is not a requirement for understanding this book or for creating .NET Enterprise Services solutions. However, if you do have COM knowledge and want to integrate existing COM components with .NET applications, this book will provide you with great information.

Organization

This book contains 15 chapters that show the services offered by .NET Enterprise Services. First, this book introduces you to all these services. It then teaches you the fundamentals of Enterprise Services by stepping into the core technologies. Finally, it describes all the services in separate chapters. With each chapter you get an architectural viewpoint of the reasons and usage scenarios of the services and then you dig into the code. After an overview of the technology you will find many code examples, so you not only learn about the features, you also learn how to use them. Throughout the book are tips and tricks that help reveal the best aspects of this technology. The final chapter presents a case study in which different services are combined so you can see them interact in a real-world scenario.

Chapter 1, "Introducing .NET Enterprise Services," provides an overview of the technologies that are related to Enterprise Services. Here you get a clear picture of what technologies you can and should use in your business solutions. A background of the evolution from MTS to COM+ and .NET Enterprise Services helps you better understand these technologies.

Chapter 2, "Object Activation and Context," covers the base technology of COM+ and .NET Enterprise Services. It provides information about how the services are made possible. You also learn about the interception mechanisms. The first serviced components are built in this chapter, and you see contexts and object activation in action.

Chapter 3, "Concurrency," teaches you the basic knowledge of running threads concurrently and how to avoid race conditions and deadlocks. After discussing COM apartment models, the chapter explains COM+ activities. Services Without Components—a new feature with COM+ 1.5—plays an important role in this chapter.

Chapter 4, "COM Interop," is ideal for those who have existing COM components that should be integrated with new .NET serviced components in their business solution. Here you learn the integration of COM and .NET technologies.

Chapter 5, "Networking," provides information about accessing the .NET Enterprise Services application using DCOM, .NET Remoting, and Web services. You will also learn which technologies are preferred based on application context.

Chapter 6, "Data Access," teaches you how to access databases with ADO.NET. This chapter not only provides an introduction to ADO.NET, it also gives you some tips and tricks on how to best use ADO.NET in a distributed environment.

Chapter 7, "Transactions," explains the ACID properties that describe a transaction (Atomicity, Consistency, Isolation, and Durability), shows you how to program transactions with ADO.NET, and describes all the transaction options and settings in .NET Enterprise Services. You'll learn about the functionality of the different features, and how to determine how your components should be configured from a transactional viewpoint.

Chapter 8, "Compensating Resource Manager," demonstrates how you can create your own resource manager that participates with the transactions of the distributed transaction coordinator (DTC).

Chapter 9, "State Management"—should you create stateful or stateless components? Where should you put the state—on the client or on the server? This chapter points out the different options of the state with various application models.

Chapter 10, "Queued Components," is an often overlooked technology with distributed solutions. In this chapter you'll read about the functionality of message queuing, and the abstraction layer Queued Components that makes it possible to invoke methods of components that are automatic-ally converted to messages and thus can be used in a disconnected environment.

Chapter 11, "Loosely Coupled Events," compares COM and .NET event models to the event model that is offered with .NET Enterprise Services. With LCE an interception model is used when the component does not directly interact with the client. You will read about how loosely coupled events can be used in different scenarios, and how filters can be defined.

Chapter 12, "Security," explains authorization, authentication, impersonation, and confidentiality concepts of a distributed solution in regard to Enterprise Services applications. Because many products interact with .NET Enterprise Services in a business solution, this chapter discusses security issues of SQL Server, ASP.NET Web applications, Web services, and .NET Remoting along with the security issues of .NET Enterprise Services itself.

Chapter 13, "Deployment and Configuration," covers how to install and configure server applications and client applications with the proxies that access the serviced components.

Chapter 14, "The Future of Distributed Applications," provides information about upcoming technologies, and how you can prepare for them in your applications today.

Chapter 15, "Case Study" is a roundup of the technologies covered in the previous chapters. It combines their features to build an application that includes technologies from the client side to the database so you can see many .NET Enterprise Services features in collaboration.

Sample Code

The sample code in this book is C#—although in Chapter 4 you can find C++, Visual Basic, and JavaScript code, which demonstrates COM interop. You can download the sample code from the book's website: http://www.christiannagel.com/EnterpriseServices. A Visual Basic .NET version of the code is also available on the website.

Contact

If you have feedback about this book or you want training and/or consulting with .NET Enterprise Services and Web services, you can contact me through my website: http://www.christiannagel.com.

Feedback is always welcome!

Christian Nagel
http://www.christiannagel.com
http://www.thinktecture.com


© Copyright Pearson Education. All rights reserved.

Foreword

Foreword

CREATING INFRASTRUCTURE-LEVEL CODE TO support complex transactional systems (including distributed transactions and even the support for compensating actions instead of simple rollback operations), fine-grained authentication capabilities, a framework for role-based authentication, the transparent support for asynchronous queuing-based interactions, an adaptive threading model, a complete process and control model, and an instrumented hosting environment which supports different levels of indirection (in-process, local, remote) is arguably one of the greatest, most fun, and most challenging things a developer can do. At the same time, it is the very task our customers don't want to see us spending time on. After all, it can hardly be said that developing these features will advance the paying customer's business in any way. One could even say that the manual implementation of all these features would fail a reasonable build-versus-buy analysis. They should be a commodity and not something you would have to create manually.

This is where Enterprise Services enters the game. It—especially the underlying COM+ framework—is an integral part of Microsoft's application server offering, which provides these features. Yes, Microsoft hasn't been talking too much about their operating system as an application server, but this is essentially what the server editions of Windows have become. We are not talking about file or print servers anymore. Today, Windows systems (and this even includes Windows CE up to a certain point) come with built-in components which would be called—and separately sold as—an application server were they developed on other platforms.

On the Windows platform, however, these application server components do not always live on the main stage. As they are essentially free modules of Windows systems, no conscious decision of whether or not they should be bought has to be made. They are just there. They are the ultimate commodity.

Unfortunately, I have noticed in the past years that only a few developers have spent time looking into these commoditized services as a base for their application's architecture. Most engineers still tend to solve the basic problems outlined above on their own. That would not necessarily be a bad thing, apart from the sad fact that it is usually very easy to get, for example, 80 percent of a transaction management system almost right. In my experience, at least, it's only the final 20 percent which can get incredibly harder. And for transactional systems, only the full 100 percent really counts. (Or would you like to go to your customer and explain that, in certain cases, the accounting system you have built is losing data even though it tells the user that everything is okay? I fear this would certainly not be a pleasant experience.) The same tends to be true for security, scalability, queuing, and instrumentation: Only the full 100 percent counts as these are essential infrastructure services.

But it might not be only selective knowledge—omitting the knowledge about COM+ or Enterprise Services—that leads to the reimplementation of infrastructure code like this. Quite the contrary might be true. If you are similar to me, you might like to approach new technology in a rather hands-down way1: Go online, get some samples, run them, change them, learn how the system reacts, dig deeper, learn, and understand. Unfortunately, Enterprise Services doesn't necessarily lead itself to this way of development. When you create your first component marked with [assembly: ApplicationActivation(ActivationOption.Server)], you will immediately notice that there is more going on under the hood than you might have thought in the first place.

Please let me speak a word of caution in this regard: The Enterprise Services framework provides very simple access to implementations of a very complex nature. From time to time, you will therefore need to deal with the complexities of large-scale distributed applications. But that's hardly the fault of the Enterprise Services framework. Instead, it is simply caused by the fact that the creation of large-scale distributed applications itself is a very complex and difficult topic. The combination of Enterprise Service's ease-of-use and its relatively high level of abstraction of a very complex topic leads to a situation in which you will have to know more than you believed you would at first glance. This is why books like this one are so important.

I have known Christian since the early days of .NET. In fact, the days were so early that .NET was still called NGWS (Next Generation of Windows Services) and C# was still codenamed Cool. Christian has always been a tremendous author, a remarkable trainer, a smart consultant with real-world experience, a good friend, and a great colleague. There are only a few people in this world who can explain Enterprise Services in reasonable depth—Christian is one of them. It is a true pleasure to see that he found the time to write this book.

Ingo Rammer
Vienna, Austria
http://www.thinktecture.com


1 This might be the Tim Taylor way of developing: "Real men don't need instructions."



© Copyright Pearson Education. All rights reserved.

Index

Download the Index file related to this title.

Updates

Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership