Enterprise Library Quick Start

Ok, I have finally got *most* of the Enterprise Library working. I thought it was going to be a quick upgrade since I have been using the Data Application and Exception Handling Blocks for several years, but it was a bit of a learning curve.

Rather than explain what they are (which is available on MSDN) or give step by step instructions (which is available upon install), I thought I would give you my “two cents” which should shorten your learning curve (at least a little).

  1. Make sure you run the “Install Services” batch file so that you get can view Performance Logs (you will see errors in your Eventlog if you don’t). (And yes you can turn them off if you don’t want to use them).
  2. I would Learn the blocks in the following order:

    1. Data Access
    2. Exception Handling
    3. Logging and Instrumentation
    4. Configuration
    Trying to do otherwise is quite difficult. For example, if you want to log your exceptions to the database, you can’t get the Exception Handling block or Logging to work without Data. And although Exception Handling requires Logging, I found it easier to learn it this way because the whole point was to log exceptions. Once my exceptions worked, then I read more about logging.
  3. To log to a database, make sure you run %Install Dir%\src\Logging\Sinks\Database\Scripts\LoggingDatabase.sql. When you set up your database to log to, it will ask what sproc to run. The default is “WriteLog”. This will create that sproc along w/ the underlying table in its own database.
  4. The connection string is now assembled for you from parameters you add to a “Connection String” node. I had to add “user id” and “password” manually.
  5. Connectionstring’s are replaced with “Databases”…sorta. In the Enterprise Library Configuration Utility you set up different “Databases” which are essentially names for connectionstrings. They host the configuration for that database.
  6. If you are used to the old Data Application Block, you will have to change your code since all the static functions are now contained in a Database wrapper class. For example:

    DataSet ds = SqlHelper.ExecuteDataset(con,storedProcedureName,parameterValues);

    will become:

    Database db = DatabaseFactory.CreateDatabase(“DATABASE NAME”);
    DataSet ds = db.ExecuteDataSet(storedProcedureName,parameterValues);

    “DATABASE NAME” is how you refer to which “database” in the Enterprise Library Config you want to run it against. Hopefully you have some type of Data Access Layer so that these changes don’t span across all your projects. Thankfully, I really only had to change about 20 references in one class.
  7. Understand that you will have to spend several hours reading through the documentation. I spent about 3 or 4 hours reading the Data Access code and converting my class to use it. Then I spent another 3 or 4 hours reading the rest.

Enterprise Library Download
Channel 9 Online Tutorials
GotDotNet Enterprise Library Message Board
Scott Mitchell’s Introduction to Enterprise Library
Enterprise Library Webcasts with Ron Jacobs

3 responses to “Enterprise Library Quick Start”

  1. Yeah, definately can’t fault you for that. Going O/R seems too cumbersome for me, but ELMAH seems nice. I remember reading about it but not liking it enought to replace my existing application block.

Leave a Reply

Your email address will not be published. Required fields are marked *