Dela via


Introduction to Enterprise Library Silverlight Integration Pack

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

patterns & practices Developer Center

On this page:
Enterprise Library | Integration Packs | Silverlight Integration Pack | What’s in This Release | Supported Scenarios - Configuration Support, Validation, Caching, Logging, Exception Handling, Interception and Policy Injection | Changes Made to Enterprise Library 5.0 in Optional Update 1 | Changes Made to Unity Interception 2.1

In this chapter, we'll discuss what the Enterprise Library 5.0 Silverlight Integration Pack is and how it relates to Enterprise Library 5.0.

Enterprise Library

Microsoft Enterprise Library is a collection of application blocks intended for use by developers who build complex, enterprise-level applications.

The goals of Enterprise Library are:

  • Consistency. All Enterprise Library application blocks feature consistent design patterns and implementation approaches.
  • Extensibility. All application blocks include defined extensibility points that allow developers to customize the behavior of the application blocks by adding their own code.
  • Ease of use. Enterprise Library offers numerous usability improvements, including a graphical configuration tool, a simpler installation procedure, and clearer and more complete documentation and samples.
  • Integration. Enterprise Library application blocks are designed to work well together or individually.

The design of application blocks encapsulates the Microsoft recommended and proven practices for Microsoft® .NET Framework-based application development. These recommended practices are demonstrated in the overall design of Enterprise Library, as well in the context-specific guidelines in the design of individual application blocks and hands-on labs. Software developers can add application blocks to Microsoft® .NET Framework-based applications quickly and easily.

For example, the Logging Application Block helps you implement diagnostic logging by providing a consistent interface that writes log messages to configurable locations, such as a file or a web service.

Integration Packs

Enterprise Library 5.0 is a general-purpose library that can be applied to many different types of applications, such as desktop applications, ASP.NET web sites, and Windows® Communication Foundation (WCF) web services.

While Enterprise Library addresses many development challenges that are common across many different environments, there are also certain development challenges that are unique to a particular environment. For example, when you are building a WCF service, you'll likely want to implement exception shielding. Enterprise Library 5.0 already ships special dlls that only make sense in specific environments, such as exception shielding in a WCF Service or validation support for a Windows Presentation Foundation (WPF) application.

The goal of an Enterprise Library Integration Pack is to take these platform-specific extensions a step further. An integration pack for a specific environment extends Enterprise Library with excellent native support for the most common scenarios in that environment. The first integration pack that ships for Enterprise Library is the Silverlight Integration Pack. Other packs targeting Microsoft Azure, ASP.NET MVC, and Microsoft SharePoint® are envisioned (see the Enterprise Library roadmap).

Silverlight Integration Pack

The Enterprise Library 5.0 Silverlight Integration Pack extends Enterprise Library 5.0 to natively support the most important scenarios when building an enterprise-scale Silverlight application. It has been built using Silverlight 4, and has been tested against Silverlight 5.0 beta. Importantly, this guidance is not targeting Windows Phone 7™ Silverlight development.

Since Silverlight uses a custom version of the common language runtime (CLR) and the .NET Framework, it is not possible to use the Enterprise Library 5.0 binaries directly in Silverlight. Therefore, the Silverlight Integration Pack uses a custom-built version of Enterprise Library. This custom-built version shares much of its code with Enterprise Library 5.0.

The custom version does not support all scenarios that the Enterprise Library 5.0 supports; some because they are not possible in Silverlight and others because they simply don't make sense. For example, it is not possible in Silverlight to log directly to the Windows Event Log or to cache directly to a database.

There are certain scenarios and development challenges that are unique to Silverlight development, which are also supported by the Silverlight Integration Pack. For example, the integration pack supports a completely new mechanism for logging messages to a WCF service, solving the problem whereby you cannot log directly to the Windows Event Log.

What’s in This Release

  • NuGet packages with binaries
    • Enterprise Library 5.0 Optional Update 1
    • Enterprise Library 5.0 Silverlight Integration Pack
    • Unity 2.1 (.NET Framework and Silverlight)
    • Unity 2.1 Interception (.NET Framework and Silverlight)
  • NuGet package with the source for Enterprise Library 5.0 Silverlight Integration Pack, which includes the source for the Optional Update 1 as well as Unity 2.1
  • Microsoft Windows Installers (MSI)
    • Enterprise Library 5.0 Optional Update 1
    • Enterprise Library 5.0 Silverlight Integration Pack
    • Unity 2.1
    • Unity 2.1 for Silverlight
  • Configuration console extension package (VSIX) for Microsoft Visual Studio® development system
  • Source code and symbols
  • Documentation
  • Stock Trader V2 reference implementation
  • QuickStarts

Supported Scenarios

In this section, we'll have a closer look at the scenarios that are supported. The following table presents an overview of the support that Enterprise Library 5.0 provides as compared to the Enterprise Library 5.0 Silverlight Integration Pack.

Conversion Error: Invalid style applied inside cell Conversion Error: Invalid style applied inside cell Conversion Error: Invalid style applied inside cell Conversion Error: Invalid style applied inside cell

Configuration

Application configuration files

Yes

No


XAML configuration files

No

Yes

Enterprise Library Core

Performance counters

Yes

No

Validation Application Block

Core Validation Application Block

Yes

Yes


ASP.NET extensions

Yes

No


WPF extensions

Yes

No


WCF extensions

Yes

No


Windows Forms extensions

Yes

No

Caching Application Block

Core Caching Application Block

Enterprise Library 5.0 implementation

New Silverlight implementation


Caching to database

Yes

No


Isolated storage

Yes

Yes

Exception Handling Application Block

Core Exception Handling Application Block

Yes

No


WCF extensions

Yes

No

Logging Application Block

Core Logging Application Block

Yes

Yes


Log formatters

Yes

No


Log to database

Yes

No


Log to Windows Event Log

Yes

No


Log to disk

Yes

No


Log to Windows message queue

Yes

No


Log to WMI

Yes

No


Log to email message

Yes

No


Log to event

No

Yes


Log to service

No

Yes


Log to isolated storage

No

Yes

Policy Injection

Core Policy Injection Application Block

Yes

Yes


Static facade

Yes

No

Unity Interception Application Block

Core Unity Interception

Yes

Yes


Validation handler

Yes

Yes


Logging handler

Yes

Yes


Exception handler

Yes

Yes


Caching handler

Yes

Yes

Security Application Block


Yes

No

Cryptography Application Block


Yes

No

Data Access Application Block


Yes

No

Configuration Support

The ability to control Enterprise Library through configuration has always been an important feature for Enterprise Library. For example, you can define in configuration where you'd like certain log messages to go, or how to handle certain exception types.

Silverlight doesn't have native support for application configuration files, such as app.config or web.config. To overcome that limitation, the Enterprise Library 5.0 Silverlight Integration Pack allows you to store configuration information in XAML configuration files. You can choose to either embed a XAML configuration file in the Silverlight XAP file or read it from an external location, such as a web server.

You can still use the Enterprise Library configuration console to configure the Enterprise Library 5.0 Silverlight Integration Pack, just as you've done with Enterprise Library 5.0. The configuration console still creates application configuration files, but you'll have several options to generate the XAML configuration files to be consumed from Silverlight:

  • A wizard in the configuration console that allows you to generate the XAML configuration file directly from the configuration console.
  • A command-line executable that helps you generate the XAML configuration file via an automated process.
  • An MSBuild task that helps you generate the XAML configuration in a build process.

To read more about the configuration support in the Enterprise Library 5.0 Silverlight Integration Pack, please read the chapter on Configuration.

Validation

When you are building an LOB application in Silverlight, you'll likely need some form of data validation support. The Enterprise Library Validation Application Block has been completely ported to Silverlight.

In the chapter on Validationin Silverlight, we'll discuss the following scenarios:

  • Sharing validation rules between client and server. To provide a good user experience, you'll likely want to run as many validation rules as possible on the Silverlight client. However, since Silverlight is a client technology, you must execute all validation rules on the server, because the validation logic on the client can be circumvented. We'll show several techniques for sharing validation rules, such as using Visual Studio linked files or using WCF RIA Services.
  • Validation in a WCF RIA Services application. WCF RIA Services has built-in support for validation and sharing validation rules between client and server. In this chapter, we'll discuss how you can extend this validation support with certain scenarios that are only provided by Enterprise Library, such as rule sets or validation rules defined in configuration.
  • Cross-tier validation in a WCF Data Services application. We'll also discuss how you can share validation rules between client and server if you are consuming WCF Data Services in Silverlight.

Caching

A common technique for improving the performance of applications involves caching data. The Enterprise Library 5.0 Silverlight Integration Pack contains an all-new implementation of the Caching Application Block. This new implementation is not based on the Enterprise Library 5.0 Caching Application Block, but is inspired by the System.Runtime.Caching namespace, which was introduced in .NET Framework 4.0, but is not yet available in Silverlight.

The Silverlight Caching Application Block supports the following scenarios:

  • In-Memory Caching. This allows you to store data in memory, with several options for specifying when cached items should expire.
  • Isolated Storage Caching. This allows you to store data in isolated storage so it is available when the application restarts.

To read more about the new Caching Application Block in the Enterprise Library 5.0 Silverlight Integration Pack, please read the Caching chapter.

Logging

Diagnostic logging and tracing is important for any enterprise application. Most of the core of the Logging Block has been converted. You can express in configuration which trace listeners you would like your log messages sent to, just as you can in Enterprise Library 5.0. The Enterprise Library 5.0 trace log providers cannot be used in Silverlight because of the Silverlight security sandbox. Therefore, the Silverlight Logging Application Block ships with its own set of trace listeners.

The Silverlight Logging Application Block supports trace listeners that allow you to perform the following actions:

  • Logging to a remote WCF Service. The Silverlight Logging Application Block allows you to handle log messages in a centralized way, by logging to a WCF Service. On the server, these log messages are handled by the Enterprise Library 5.0 Logging Application Block. You can send the log messages as they are logged, or in a batch, and buffer them in memory or in isolated storage.
  • Logging to isolated storage. If you wish to write log information to a persistent store in your Silverlight application, you can also write your log messages to isolated storage.
  • Logging to an event. The Silverlight Logging Application Block can also raise an event every time a certain log message is received. You can use this to build a custom trace log view in your application, for example.

The Enterprise Library 5.0 Silverlight Integration Pack also supports the use of tracers. A tracer allows you to correlate log messages that are part of the same logical operation. We'll show you how you can apply tracers to asynchronous operations.

To read more about the Logging Application Block in the Enterprise Library 5.0 Silverlight Integration Pack, please read the Diagnostic Logging and Tracingchapter.

Exception Handling

The Exception Handling Application Block has been fully ported to Silverlight. With it, you can define how you'd like to handle exceptions by defining exception handling policies.

Exception handling in synchronous method calls is fairly straightforward. However, because all web service calls in Silverlight are asynchronous, we're also showing how you can apply exception handling for asynchronous operations.

To read more about exception handling in a Silverlight application using the Exception Handling Application Block, please read the Exception Handling chapter.

Interception and Policy Injection

Interception is an advanced programming technique that provides a non-intrusive way to intercept calls to objects and allows you execute custom code before or after the call. You can use this, for example, to transparently add caching, logging, exception handling, validation, or custom logic to certain objects.

Unity Interception has also been fully ported to Silverlight, with the exception of the TransparentProxyInterceptor. Policy injection is also supported through the Unity Interception interface. The chapter on Interception describes in more detail what interception and policy injection are and how you can apply them in your application.

Changes Made to Enterprise Library 5.0 in Optional Update 1

Optional Update 1 contains minor changes made to Enterprise Library 5.0 to support certain Silverlight-specific scenarios. The changes include:

  • Version numbers. The version number for all Enterprise Library assemblies has been updated to: 5.0.505.0. Even though only a few assemblies have actually been changed, they have all been given a higher version number to prevent version mismatch issues.
  • Validation attributes. To support the WCF RIA Services code generation, all validation attributes from the Validation Application Block had to be updated to include public read-only properties for each constructor parameter. For the RangeValidatorAttribute and the DateTimeRangeValidator attribute, the LowerBound and UpperBound properties have been changed to type Object.
  • Validation result. The ToString method is now overridden and will return the message of the validation result. This makes it easier to bind the validation result to a visual element.
  • Validation configuration objects. To support the XAML markup, the constructor parameters for the validation configuration objects have been removed and converted to properties.
  • Enterprise Library validation extension for Unity fix.
  • File configuration source with relative pathsfix.
  • Profiles added to configuration console. The configuration console now supports profiles. If you use the Silverlight profile, only the blocks and options available for Silverlight development are visible. If you use the desktop profile, only the blocks and options that are available for the desktop are visible. You can also choose to run without a profile so that all blocks and options are visible.
  • Minor usability fixes to configuration console.
  • Export to XAML wizard added in configuration console. A new configuration console wizard, called the Export To XAML wizard is shipped with the Enterprise Library Silverlight Integration Pack. This wizard exports the configuration file to XAML, so that the configuration can be consumed from a Silverlight application.

Changes Made to Unity Interception 2.1

The following problems have been fixed in Unity Interception 2.1:

  • Hidden Property Causes AmbiguousMatchException in InterceptionExtension.
  • Unity Interception: Interface interception problem when using VS 2010.
  • The ParameterCollection type in the Unity Interception Extension has a new method to query if a parameter with a given name exists in the collection.
  • Using InterfaceInterceptor on a class that contains a method with a generic type that is constrained by another generic type.
  • Unity InterfaceInterceptor is not wrapping a resolved derived class that contains no members, even when its base class does.
  • Unity VirtualMethodInterceptor incorrectly overrides methods with generic constraints.

Next Topic | Previous Topic | Home

Last built: July 8, 2011