This was a great first TechEd session for me.  It went into some detail on the application blocks available as part of the Enterprise Library:

  • Caching
  • Configuration
  • Cryptography
  • Data Access
  • Exception Handling
  • Logging & Instrumentation
  • Security

One thing that I really like is that the Enterprise Library comes with a configuration tool that will open the web.config file and make all of the appropriate entries.

DATA APPLICATION BLOCK

Uses the connection strings defined in the web.config file (nice to see).
General model is to create the database with a factory, create the command object (DbCommand), add parameters, and then execute / fill the dataset.
Provides a layer of abstraction to promote database independence, but I have to wonder how useful this really is.  It’s a little more streamlined than ADO.NET, but I’m hesitant to complicate things further.

EXCEPTION HANDLING BLOCK

Easy to create different policies (e.g. by application layer).
Exception formatters – use in FormatterType.
Configuration of policy works like Try/Catch… you specify types and then the first one that matches is what gets executed.
You still have to write a Try/Catch block, but from that block you call into Microsoft.Practices.EnterpriseLibrary… and then if a true is returned you rethrow the error.
To log errors into the database, you can put code in the Global.asax file that leverages the logging block.

LOGGING BLOCK

Can be configured to use MSMQ + Distributor Service
You can configure TraceListeners for database / e-mail / etc.
There is a script you run to create the “Logging” dtabase.

TRACING APPLICATION BLOCK

Create a Using block that creates a new Tracing object.
Time that the Tracing object is created and destroyed will be logged.
Can create Event Log entries when it starts and ends.
Can also log to DB using Trace Listener.

SECURITY APPLICATION BLOCK

Can provide more granular control over built-in URL security mechanism in .NET 2.0.
Lets you create custom rules based on the Principle object.

CRYPTOGRAPHY APPLICATION BLOCK

Wraps built-in cryptography mechanisms.
Encorporates best practices, such as adding salt before creating hashes.