C# and C++

Windows Workflow Foundation 3.0

Chapter 57: Windows Workflow Foundation 3.0

What’s in This Chapter?

  • Different types of workflows: Sequential and State Machine

  • Built-in activities

  • Creating custom activities

  • Workflow Services

  • Integration with WCF

  • Hosting Workflows

  • Tips for migrating to Workflow Foundation 4

This chapter presents an overview of the Windows Workflow Foundation 3.0 (known as WF throughout the rest of this chapter), which provides a model to define and execute processes using a set of building blocks called activities. WF provides a Designer that, by default, is hosted within Visual Studio, and that allows you to drag and drop activities from the toolbox onto the design surface to create a workflow template.

This template can then be executed by creating a WorkflowInstance and then running that instance. The code that executes a workflow is known as the WorkflowRuntime, and this object can also host a number of services that the running workflows can access. At any time, there may be several workflow instances executing, and the runtime deals with scheduling these instances and saving and restoring state; it can also record the behavior of each workflow instance as it executes.

Tags:

LINQ to SQL

Chapter 56: LINQ to SQL

What’s In This Chapter?

  • Working with LINQ to SQL using Visual Studio 2010

  • Mapping LINQ to SQL objects to database entities

  • Building LINQ to SQL operations without the O/R Designer

  • Using the O/R Designer with custom objects

  • Querying the SQL Server database using LINQ

  • Stored procedures and LINQ to SQL

You will probably find the .NET Language Integrated Query Framework (LINQ) in C# 2010 to be one of the more exciting features the language has to offer. Basically, what LINQ provides is a lightweight façade over programmatic data integration. This is such a big deal because data is king.

Pretty much every application deals with data in some manner, whether that data comes from memory (in-memory data), databases, XML files, text files, or something else. Many developers find it very difficult to move from the strongly typed object-oriented world of C# to the data tier where objects are second-class citizens. The transition from one world to the next was a kludge at best and was full of error-prone actions.

In C#, programming with objects means a wonderful, strongly typed ability to work with code. You can navigate very easily through the namespaces, work with a debugger in the Visual Studio IDE, and more. However, when you have to access data, you will notice that things are dramatically different.

Tags:

Web Services with ASP.NET

Chapter 55: Web Services with ASP.NET

What’s In This Chapter

  • The syntax of SOAP and WSDL

  • How SOAP and WSDL are used by web services

  • Exposing and consuming web services

  • The use of web services

  • Exchanging data by using SOAP headers

Web services are a way of performing remote method calls over HTTP that can make use of Simple Object Access Protocol (SOAP). In the past, this issue was fraught with difficulty, as anyone who has any DCOM (Distributed COM) experience knows. Using older technologies, the act of instantiating an object on a remote server, calling a method, and obtaining the result, is far from simple, and the necessary configuration is even trickier.

SOAP simplifies matters immensely. This technology is an XML-based standard that details how method calls can be made over HTTP in a reproducible manner. A remote SOAP server is capable of understanding these calls and performing all the hard work for you, such as instantiating the required object, making the call, and returning a SOAP-formatted response to the client.

The .NET Framework makes it very easy for you to do this. As with ASP.NET, you are able to use the full array of C# and .NET techniques on the server, but (perhaps more importantly) the simple consumption of web services can be achieved from any platform with HTTP access to the server. In other words, it is conceivable that Linux code could, for example, use ASP.NET web services, or even Internet-enabled fridges. To quote a real-world example, in the past I have had great success combining ASP.NET web services with Macromedia Flash to create data-enabled flash content.

Tags:

.NET Remoting

Chapter 54: .NET Remoting

What’s In This Chapter?

  • An overview of .NET Remoting

  • Contexts, which are used to group objects with similar execution requirements

  • Implementing a simple remote object, client, and server

  • The .NET Remoting architecture

  • .NET Remoting configuration files

  • Hosting .NET Remoting objects in ASP.NET

  • Using Soapsuds to access the metadata of remote objects

  • Calling .NET Remoting methods asynchronously

  • Calling methods in the client with the help of events

  • Using the CallContext to automatically pass data to the server

This chapter explores .NET Remoting. .NET Remoting can be used for accessing objects in another application domain (for example, on another server). It provides a faster format for communication between .NET applications on both the client and the server side.

In this chapter, you develop .NET Remoting objects, clients, and servers by using the HTTP, TCP, and IPC channels. First, you configure the client and server programmatically before you change the application to use configuration files instead, where only a few .NET Remoting methods are required. You also write small programs to use .NET Remoting asynchronously and for calling event handlers in the client application.

The .NET Remoting classes can be found in the namespace System.Runtime.Remoting and its subnamespaces. Many of these classes are in the core assembly mscorlib, and some needed only for cross-network communication are available in the assembly System.Runtime.Remoting.

This article is excerpted from chapter 54 ".NET Remoting" of the book "Professional C# 4 and .NET 4" by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner (ISBN: 978-0-470-50225-9, Wrox, 2010, Copyright Wiley Publishing Inc.)

Tags:

C#, Visual Basic, C++/CLI, and F#

Chapter 53: C#, Visual Basic, C++/CLI, and

F#

What’s In This Chapter?

  • Namespaces

  • Defining types

  • Methods

  • Arrays

  • Control statements

  • Loops

  • Exception handling

  • Inheritance

  • Resource management

  • Delegates

  • Events

  • Generics

  • LINQ queries

  • C++/CLI mixing native and managed code

C# is the programming language designed for .NET. More than 50 languages exist for writing .NET applications—for example, Eiffel, Smalltalk, COBOL, Haskell, Pizza, Pascal, Delphi, Oberon, Prolog, and Ruby. Microsoft alone delivers the languages C#, Visual Basic, C++/CLI, J#, JScript.NET, and F#.

Every language has advantages and disadvantages; some things can be done easily with one language but are complicated with another one. The classes from the .NET Framework are always the same, but the syntax of the language abstracts various features from the framework. For example, the C# using statement makes it easy to use the objects implementing the IDisposable interface. Other languages need more code for the same functionality.

Tags:

Directory Services

Chapter 52: Directory Services

What’s in This Chapter?

  • The architecture and concepts of Active Directory

  • Tools for accessing the Active Directory

  • How to read and modify data in Active Directory

  • Searching for objects in Active Directory

  • User and group management programmatically

  • Using DSML (Directory Service Markup Language) to access the Active Directory

Microsoft’s Active Directory is a directory service that provides a central, hierarchical store for user information, network resources, services, and so on. The information in this directory service can be extended to also store custom data that is of interest for the enterprise. For example, Microsoft Exchange Server and Microsoft Dynamics use Active Directory extensively to store public folders and other items.

Before the release of Active Directory, Exchange Server used its own private store for its objects. It was necessary for a system administrator to configure two user IDs for a single person: a user account in the Windows NT domain to enable a logon and a user in Exchange Directory. This was necessary because of the additional information required by users (such as e-mail addresses, phone numbers, and so on), and the user information for the NT domain was not extensible to add the required information.

Now, the system administrator has to configure just a single user for a person in Active Directory; the information for a user object can be extended so that it fits the requirements of Exchange Server. You can also extend this information. For example, you can extend user information in Active Directory with a skills list. Then, it would easily be possible to track down a C# developer by searching for the required C# skill.

This chapter shows how you can use the .NET Framework to access and manipulate the data in a directory service using classes from the System.DirectoryServices, System.DirectoryServices.AccountManagement, and System.DirectoryServices.Protocols namespaces.

Tags:

Enterprise Services

Chapter 51: Enterprise Services

What’s In This Chapter?

  • Features of Enterprise Services

  • Using Enterprise Services

  • Creating a serviced component

  • Deploying COM+ applications

  • Using transactions with COM+

  • Creating a WCF façade to Enterprise Services

  • Using Enterprise Services from a WCF client

Enterprise Services is the name of the Microsoft application server technology that offers services for distributed solutions. Enterprise Services is based on the COM+ technology that has already been in use for many years. However, instead of wrapping .NET objects as COM objects to use these services, .NET offers extensions for .NET components to take direct advantage of these services. With .NET you get easy access to COM+ services for .NET components.

Tags:

Managed Add-In Framework

Chapter 50: Managed Add-In Framework

What’s In This Chapter?

  • Architecture of the Managed Add-In Framework

  • Defining a Contract

  • Implementing a Pipeline

  • Creating Add-Ins

  • Hosting Add-Ins

This chapter describes in detail the Managed Add-In Framework (MAF) architecture and how to create add-ins and host add-ins using MAF. You can read about the architecture of MAF and what issues it solves by hosting add-ins, such as versioning, discovery, activation, and isolation. Then we discuss all the steps that are necessary to create the MAF pipeline that is used to connect the add-in with the host; how to create add-ins; and how to create a hosting application that uses add-ins.

This article is excerpted from chapter 50 "Managed Add-In Framework" of the book "Professional C# 4 and .NET 4" by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner (ISBN: 978-0-470-50225-9, Wrox, 2010, Copyright Wiley Publishing Inc.)

Tags:

Visual Studio Tools for Office

Chapter 49: Visual Studio Tools for Office

What’s In This Chapter?

  • What types of projects you can create with VSTO and what capabilities you can include in these projects

  • Fundamental techniques that apply to all types of VSTO solutions

  • Using host items and host controls

  • Building VSTO solutions with a custom UI

Visual Studio Tools for Office (VSTO) is a technology that enables you to customize and extend Microsoft Office applications and documents by using the .NET Framework. It also includes tools that you can use to make this customization easier in Visual Studio—for example, a visual designer for Office Ribbon controls.

Tags:

Graphics with GDI+

Chapter 48: Graphics with GDI+

What’s In This Chapter?

  • Principles of drawing
  • Colors and the safety palette
  • Pens and brushes
  • Lines and simple shapes
  • BMP images and other image files
  • Drawing Text
  • Fonts and font families
  • Dealing with printing

You will notice that quite a number of chapters in this book deal with user interaction and the .NET Framework. Chapter 39, “Windows Forms,” focused on how to display either a dialog box or a Single Document Interface (SDI) or Multiple Document Interface (MDI) window, and how to place various controls such as buttons, text boxes, and list boxes. It also looked at how to work with data in Windows Forms using a number of the Windows Forms controls that work with the disparate data sources that you might encounter.

Tags:
Syndicate content