MSDN Magazine article on building your own application block

The July 2006 edition of MSDN Magazine arrived in my mailbox today, and it contains a great article called Speed Development With Custom Application Blocks For Enterprise Library written by Mark Seeman. In this day of digital everything, it's nice to actually be able to hold something tangible in your hand - so I read the article on my balcony while enjoying the afternoon sun. But for those of you without some combination of an MSDN Magazine subscription, a balcony, or the sun, the link above will take you to ths same content online.

Comments (7)
  1. Dmitry says:

    Hi Tom,

    Quick question about instrumentation in Ent Lib 2.0. I am trying to follow the documentation and instrument my own classes using [InstrumentationListener] and [InstrumentationProvider] but have had no luck so far. Is there anything specific that needs to be done in order to actually make it work?

    Any comments would be very much appreciated!

    Here is the code from the Ent Lib documentation which I tried:

    public partial class Form1 : Form


      public Form1()




      private void button1_Click

        (object sender, EventArgs e)


        MyApplication appl =

        new MyApplication();


        //Object reference not set

        //to an instance of an object.





    public class MyApplication



    public event EventHandler<EventArgs>


    public void FireOnDbConnect()


      OnDbConnect(this, new EventArgs());



    public class MyListener


    public MyListener(string instanceName,

         bool a, bool b, bool c)

     { }


        public void ConnectObserved

          (object sender, EventArgs e)



              "I saw a Database Connect.");



  2. Dmitry says:

    … just a quick comment about my last question about instrumentation. I did reference Common and ObjectBuilder DLLs and set enabled Instrumentation in the config file.



  3. Dmitry says:

    …further to my previous post about Instrumentation. After digging Ent Lib 2.0 source code I finally was able to instrument my own classes. It would be very helpful if this topic could get a little bit more coverage in the documentation since the examples that are provided there aren’t really enough. Other than that I must say it works great!


  4. Lizet says:

    Hi all,

    I had asked a related question, but let me re-word the problem.

    I’m trying to log extra information depending on the type of exception that occurs. When defining a policy with the Enterprise Handling Configuration Tool all the exceptions that are caught are logged the same, this is, the logged entry has the following properties:

    Timestamp: {timestamp}

    Message: {message}

    Category: {category}

    Priority: {priority}

    EventId: {eventid}

    Severity: {severity}


    Machine: {machine}

    Application Domain: {appDomain}

    Process Id: {processId}

    Process Name: {processName}

    Win32 Thread Id: {win32ThreadId}

    Thread Name: {threadName}

    Extended Properties: {dictionary({key} – {value} )}

    However an HttpUnhandledException is logged the same way as a System.Net.WebException, we would like to log the WebExceptionStatus.ProtocolError for this type of exception. This is we would like to log the extra properties depending on the type of the exception. The Extended Properties dictionary is empty in all cases.

    How do we log extra properties such as the query string, the page name, the authenticated user and so on? What do we tweak while we define the policy using the Exception Handling Tool to log this extra information?

    Thanks in advanced,


  5. Krishna says:

    Hi All,

    I am using DatabaseTraceListener for some of my Categories. So i find script in enterprise library and run in my database.In the configuration i till this is my addstoredprocedure and writelogstoredprocedure.

    and it all runs fine.

    But i want add more

    SiteName, UserName and some other info logged into the database.

    How can i do that?

    Somebody please refer me a document or i can look for such information.


  6. Krishna – you’ll need to modify your database schema, and then modify the code for the DatabaseTraceListener to insert the desired data into your new columns.


  7. Dmitry says:

    Just posted a sample code for the intrumentation on msdn forums. Here is the link:

Comments are closed.

Skip to main content