Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

Getting Started with Enterprise Library!

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.

[tags:enterprise library]

This entry was posted in .NET General. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

2 Responses to Getting Started with Enterprise Library!

  1. Sups says:

    Lets see the sample application. Did u also try this on an asp.net app.?

  2. JosephCooney says:

    Patterns & Practices have a serise of webcasts on using the Enterprise Library – check out http://www.pnplive.com/

Leave a Reply