Enterprise Library customization

Microsoft Enterprise Library is undoubtedly a great resource to support your .NET development. It is a bunch of some excellent tools and programming libraries to facilitate best practices in core areas of programming including data access, security, logging, caching, exception handling and others. Using the library without feeling the need to change any of the code is fairly easy and simple. However, while customizing it, we need to take special care as we might need to touch upon many areas than just source code. Today, I went through this customization process myself and faced a few difficulties which are worth mentioning here in order to help others avoid the same. I wanted to modify the contents of {Message} token for text formatter template and what I experienced was:

  • EntLib41Src folder is the point to start from which has got everything including blocks source code, scripts to build the modified libraries, quick starts etc. We are not supposed to touch actual Enterprise Library installation folder.

  • Before we actually proceed, we can open QuickStarts projects to help ourselves identify the file and method that we wish to change.

  • Now, we modify the code. I commented the call to WriteDescription() and WriteDateTime(DateTime.UTCNow) functions inside Format method and call to this.WriteSource and this.WriteHelpLink functions inside WriteException method in ExceptionFormatter.cs file.

  • We need to create a strong name key in order to generate strong-name EL assemblies. Check this out here: Strong Naming the Enterprise Library Assemblies

  • We can execute BuildLibrary.bat and CopyAssemblies.bat in order to build the modified assemblies and copy them to EntLib41Src\bin\ respectively.

  • Reference the assemblies in the project.

  • Make sure from that point onwards, we use the right copy of Enterprise Library Configuration tool which is inside EntLib41Src\bin\EntLibConfig.exe otherwise, we might end facing errors and exceptions related to assembly versioning and manifest definition mismatch as Tom Hollander describes it in his blog here: Avoiding configuration pitfalls with incompatible copies of Enterprise Library

Khallas! we are done.

0 comments:

Post a Comment