This post originated from an RSS feed registered with .NET Buzz
by Pau Laudeman.
Original Post: Getting Started with Enterprise Library!
Feed Title: Paul Laudeman
Feed URL: /error.htm?aspxerrorpath=/blogs/paul.laudeman/rss.aspx
Feed Description: Helping You to Make "Smart Clients" Smarter!
Recently we had the need to implement a more standardized way of logging information and handling exceptions in our SharePoint Portal webparts. In previous applications, we have used the various Microsoft Application Blocks and other tools (such as log4net) for our needs. If you havenât heard yet, the âEnterprise Libraryâ is the next generation of Microsoft's Application Blocks featuring new enhancements and improvements based on community feedback.
This past weekend I finally had the opportunity to sit down and spend some time with the library by integrating it into a simple application I came up with to demonstrate the various new blocks. My sample Windows Forms application used the Caching, Configuration, Data, Exception Handling, and Logging blocks. While the application itself was a bit contrived (consisting of a single form that displayed a bunch of Northwind customers in a grid), the actual implementation of the blocks was done to satisfy real world needs (exception handling, logging, diagnostics, etc.). (If there is any interest, I can link to the demo project.)
Based on my experiences so far, here are my favorite features of the new library:
Consistent configuration experience across all blocks. Each block can be used separately or combined with one another in complimentary ways.
Highly configurable. If youâre using the logging block, for example, you can specify sinks (destinations) of where you want your logs to go. Out of the box you can specify the event log (the default), email, flat files, MSMQ, or WMI.
Shipped with unit tests! In the past Iâve modified the behavior of some of the blocks but lacked the means necessary to regression test my changes. Now with the unit tests shipping as part of the default install, I can be more confident that any changes I make wonât break existing code.
Consistent experience performing common tasks between Windows Forms and ASP.NET. Using the Enterprise Library blocks allows me to program against the same API no matter if I'm building a Windows Forms apps or ASP.NET apps. For example, I can easily take advantage of caching now on both smart clients and ASP.NET -- before I had to roll my own cache engine for a Windows app or reference the caching framework of ASP.NET directly (yuck!).
Here are some tips to get you started:
Make sure you run the install script after completing the setup to install the additional WMI support and other performance counters for the blocks themselves (click the âInstall Servicesâ link in the program group folder).
Spend some time looking through the docs that ship with the product to get yourself acquainted with what all the Enterprise Library blocks have to offer â donât be intimidated by the configuration interface and all the XML configuration files (psst, itâs a lot easier to set up and use than it looks!).
You donât need to rip and replace existing code that uses the older version of the application blocks â start looking for opportunities to use the new library blocks in your new projects where it makes sense.
â¦and some more resources:
See Channel 9 for an Enterprise Library Wiki with links to resources to help get you started
Ron Jacobs, Product Manager for p&p, has quite a few links of interest on his website at www.ronjacobs.com including links to webcasts and hands-on labs that you can download. (For some extra entertainment, be sure to check out his podcasts!)
Fellow CodeBetter blogger Mark Digiovanni presented recently on Enterprise Library featuring a custom data provider to interface with VistaDB (link).
Be sure to check out the Rolling File Sink for the logging block, shipped separately, that allows you to have fine grained control on how your logs are managed.
Check out these bloggers from the patterns & practices group: Ron Jacobs, Scott Densmore, and Tom Hollander (wow, what a crew! where can I sign up?)
Enterprise Library Workspace on GotDotNet where you can download the latest releases and participate in the community around these blocks
â¦and finally!
Start thinking about how to implement these blocks from the outset of your project! By learning about these blocks and implementing them from day one, you will give yourself a solid foundation to upon which you can confidently build your application â rather than worrying about if you should have done it when youâre at the end of your dev cycle and then wonder how you can do it at the eleventh hour before you ship.