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).
- 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).
- I would Learn the blocks in the following order:
- Data Access
- Exception Handling
- Logging and Instrumentation
- Data Access
- 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.
- 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.
- 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.
- 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);%MINIFYHTML3b4a2ce2f1799c39719d854d16e301d63%%MINIFYHTML3b4a2ce2f1799c39719d854d16e301d64%
“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.
Database db = DatabaseFactory.CreateDatabase(“DATABASE NAME”);
DataSet ds = db.ExecuteDataSet(storedProcedureName,parameterValues);
- 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