Jean Hibbert's Blog

.NET Framework, SQL Server and other random thoughts.
Write your own web server in less than 40 lines

I've recently been toying with the System.Net.Sockets namespace... and this is how easy it is to write your own web server:

using System;

using System.Collections.Generic;

using System.Text;

using System.Net;

using System.IO;

using System.Net.Sockets;

using System.Threading;

 

namespace MyFirstWebServer

{

    class Program

    {

        static void Main(string[] args)

        {

            TcpListener listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 8010);

            listener.Start();

            TcpClient client = listener.AcceptTcpClient();

            NetworkStream networkStream = client.GetStream();

            StreamReader reader = new StreamReader(networkStream);

            StreamWriter writer = new StreamWriter(networkStream);

            String line = reader.ReadLine();

            while (line != null && line.Length > 0)

            {

                Console.WriteLine(line);

                line = reader.ReadLine();

            }

            writer.WriteLine("<html><head><title>Hello World!</title></head><body>Hello World!</body></html>");

            writer.Flush();

            networkStream.Close();

            reader.Close();

            writer.Close();

            while (true)

            {

                Thread.Sleep(1000);

            }

        }

    }

}

The TCPListener accepts a pending connection request, writes out the request header to the console and returns the HTML string containing the "hello world".

The header output from the browser request:

 

The HTML string sent back to the browser:

 

Easy peasy lemon squeezy.

 

Patterns and Practices Summit 2008 - Day 5

 1. John De Vos, David Hill & Ajoy Krishnamoorthy - P&P Looking ahead : These guys are the P&P architects and they wanted to know how we felt about the current set of Enterprise Library tools. They also did a bit of horn blowing by providing us with the general usage statistics for the Enterprise Library in the development community.

I made a point of standing up and stressing the importance of having StarterKits for the different Ent Lib tools. I also stressed the importance of the Astoria framework for developers that work on multi-tier applications. :-P They referred me to their "Reference Implementations". (I need to look into this.)

2. Keynote - Scott Guthrie :  Scott Guthrie gave some insight into Microsoft's up and coming technologies and mentioned something that had been bothering me since toying with the ASP.NET MVC framework. ASP.NET servercontrols WILL be fully supported in ASP.NET MVC  applications in ASP.NET 4.0. He did not specifically mention that "ASP.NET 4.0" but if you read between the lines, ASP.NET 4.0 will be a hybrid of the MVC framework and Webforms technologies. Naaaaiiiicccceeeee. :-)

3. Billy Hollis - Drowning in Complexity : Once again Billy's session rocked the house. He crystalized a lot of my thoughts with regards to the Agile software development methodology. I totally agree, that it's a methodology invented by "Code Addicts", and he also pointed out how we...(us developers) and the general users of Microsoft's technologies are partly to blame for the complexity issues we face today due to our "Feature Hungry Mentality". Apple has managed to avoid this trap by building simple and easy to use devices like the iPhone and iPod. The key to their success lies in their simple and intuitive design.

Patterns and Practices Summit 2008 - Day 4

1. Keynote - David Treadwell: This talk focused on cloud computing and David gave a demonsration of the how a "mesh" application would work.

2. David Hill & Kyle Huntley - Composition and presentation patterns : What a brilliant talk! David and Kyle took us through a WPF/Silverlight applicaton where the only differentiation was the UI skin!!! He showed how by implementing this pattern a WPF application can be easily upgraded to a Silverlight application. The application leveraged the Unity framework.

3. Rocky Lhotka - Porting CSLA to Silverlight: Rocky gave an overview of the CSLA framework. I agree with Rocky's general outlook on software design, but I felt he was very vague on how CSLA can be implemented and used. Personally I think he was trying to avoid making his talk sound like a sales pitch.

4. Drew Miller - Distributed caching : This was a very good talk on Distributed caching in multi-tier and web farm scenarios. It's worth investigating Velocity by Microsoft and MemCache. There are some good webcasts on Velocity that can be found here.

5. Erwin Van Der Valk - Presentation Layer Anti-Patterns: Erwin gave a good talk about the challenges that face UI developers, and and some insight into his experiences during his career.

6. Ward Bell - Lessons in Data Driven Silverlight Applications : Ward demonstrated a Silverlight application that performed the basic CRUD and included security membership features. He also stressed that developing in Silverlight would mean that the developer would have to adopt the "Asynchronous" mindset.

 

Patterns and Practices Summit 2008 - Day 3

1. Keynote - Pat Helland : Pat gave a brilliant speech on the energy consumption of data centers. He gave us insight into the setup of Microsofts data centers and the strategies Microsoft use to conserve energy and keep costs low. This was an unexpected subject, but Pat is somebody definitely worth keeping an eye on.

2. Data Access - Don Smith : Don gave us a talk and demonstration on the Entity framework. At the end of the session I had a chat with him and asked him what Microsoft is doing to facilitate the integration of the DAL into the middle-tier. He said I should take a look at the REST & ADO.NET Data Services.

3. Evolutionary Design - Jim Newkirk : Jim gave a talk about how to avoid complexity in appications, and the general message was LESS IS MORE a lot of the time when it gets to shipping features. Rather make sure the features you provide work properly than try to ship too many features prematurely.

4. ESB Guidance - Dimitri Ossipov : Dimitri demonstrated the new ESB tools in VS 2010. He created services and their contracts in a designer and built a basic ESB architecture.

5. Architecture, simple or hard - Rocky Lhotka : This is probably my favourite talk so far. Rocky gave a good overview of the complexities that arise in multi-tier architectures, and some of the pitfalls we fall into that cause our applications generate unecessary complexity.

6. Pumping Iron - Dynamic languages in .NET - Harry Pierson : Harry wrote a XML parser in Iron python and gave some insight into the streanghs of this dynamic language. It looks really cool!

7. Dynamic Rules Driven Architecture - Billy Hollis : As always Billy was on top form :-) He showed how by creating rules driven architectures in our applications we can allow the client to extend their systems, as new business requirements materialise. I had a chat with Billy afterwards and got a few good ideas for one of the systems I own. Silverlight is looking like an extremely viable technology nowadays. ;-)

Evening Dinner with the Microsoft Research Team

This was an incredible experience and a real eye opener in terms of how Microsoft judge the success of thier products and some of the new development features on the horizon.

Some of the tools:

PEX : This generates unit test for projects that test every permutation of argument for each method. Bluddy awesome.

CHESS: This is a tool that allows you to catch threading bugs and replay them i.e. replicate them. Also really amazing.

Both of the tools above are available for VS 2008. (Keep an eye on the licensing though)

An architect here at P&P who attended the PDC last week said I should take a look at http://www.microsoftpdc.com/ where are the seminars are available to view.

Enjoy.

Patterns and Practices Summit 2008 - Day 2

1. Keynote - Kent Beck : - This guy is the father of XP programming. The talk he gave was about the philosopy behind problem solving, and a few key techniques we can use to tackle problems.

They were. a) Have the guts to make the LEAP sometimes. b) Somtimes its critical to SIMPLIFY c) Sometimes it's usefull to REWRITE the system in paralell to maintaining the system. d) It's always important to REFACTOR.

2.  Architecture without big design - Peter Provost: This was an introduction into Architect Explorer which will be released with VS 2010. Download the VS 2010 CTP while you are at it and give it a whirl.

Also there is a C# application called RAWR for World of warcraft players thats worth investigating. This was the application Peter Provost used in his Architecture Explorer demo. I need to get a copy of World of Warcraft for myself when I return! :)

3.  Distributed Agile - Ade Miller : This guy spoke about how the Patterns and Practices team manages distributed team members. The final conclusion is that its very difficult and should be avoided if possible. NOTE: My take on team members bieng allowed to "work from home" should only occur in extreme circumstances.

4. TFS at Microsoft - Stephanie Saad : This woman gave us insight as to how Microsoft uses TFS. It was good to see that Microsoft also go through some of the pain points that we do.

5. Agile Development - Gabe Brown : Two of the Agile evangelists at  Micorosft gave insight into strategies which they use to bring out quality software. They ALWAYS keep the Enterprise Library in a shippable state, and force each feature through "Quality Gates". This is a brilliant strategy.

I'll be compiling an email about this strategy to my work colleagues when I get back.

6.  Acceptance testing - Grigori Melnik : This was about strategies for testing software in an Agile environment. Powerfull strategies for any Software develoment house.

7. Building Manageable applications - Alex Homer: This is one of my favourite speakers and I stayed late to chat to him personally aftwards.

He spoke about Health Monitoring Instrumentation Strategies, and the tools out there. I managed to extract some usefull ideas here for monitoring service applications. Dependency injection is a key building block here in terms of making your health/performance monitoring functionality extensible.

Cheers for now.

Patterns and Practices Summit 2008 - Day 1

1. Keynot Jeff Teper - This guy did an overview of sharepoint and the future of the product.

2. Functional programming - Erik Meijer : I've been looking forward to this talk for a while. Erik M. is one of the architects that works with Anders H.

Erik gave some brilliant insight into the evolution of programming languages and pointed us to a Language called Haskell which is a pure functional language and would be an ideal introduction into this sphere. 

A book we were advised to read : Graham Hutton - Programming in Haskell

3.  Application Architecture - JD Meier : This was a chat about the new application architecture book comming out by Microsoft. This book look very relevant to all developers.

http://www.codeplex.com/AppArch

4. Enterprise Library 4.1 - This was a talk on the performance improvements as well as how the Enterprise library has been made more extensible.

5. MVC & Dynamic Data : A chat and demo of the ASP.NET MVC framework and HTML Helpers.There seems to be a new way of depicting custom controls in ASP.NET.

6. MEF Framework - Glen Block: This is an extensibility framework which is extremely simple to implement using attributes. Applications can be extended at runtime just by dropping an extension library into a defined folder.

7. Agile Security - Bryan Sullivan: A view on how to ensure your applications are secure and the tools which Microsoft use to verify thier applications are secure.

 

Seattle Day 1 - Sunday

The jet lag was pretty rough.... I still find myself waking up at wierd hours of the night and checking the time. I also have a lot on my mind at the moment, and am looking forward to the conference which kicks off in 1 hour.

This blog post is about yesterday though. I managed to watch the Seattle Seahawks play the Philidelphia Eagles, ... the "Battle of the Birds". American football has always made more sense than rugby to me.You can tackle whoever the hell you please and you can throw the ball in any direction.... although I feel the game doesn't flow as well as rugby.

Strange and way out experiences so far include:

- The guy next to me at the football game getting chucked out of the stadium for gyrating his hips at the local supporters and pissing off the woman behind him. The "sprinkler routine" he performed every time the eagles scored was classic.

- The guys I met yesterday were cool. I got to chat with them and taste some of the local beverages.

Posted: Nov 03 2008, 11:19 PM by jean
Filed under:
Patterns & Practices Summit 2008

I will be attending the Patterns and Practices summit 2008, which starts next week.

A list of speakers
http://www.pnpsummit.com/west2008/west2008.aspx

General topics
http://www.pnpsummit.com/West2008/west2008sessions.aspx

I attended the 2005 patterns and practices summit(the year before I joined m35) and found this conference extremely informative with regards to:

1) Gaining insight into the .Net Framework, and design patterns.
2) Learning about the Enterprise Library.
3) Learning about the new Infragistics controls. (Infragistics do talks on their .Net framework controls because they are one of the sponsors).
4) Gain a stronger understanding of Design Architecture which is an art that is always evolving.

The talks I am looking forward to are:

Drowning in Complexity: What You Can Do About It - Billy Hollis

What's the biggest problem facing architects and developers today. Billy Hollis believes that it's the extreme and ever-increasing complexity of the technologies we use as platforms. In this session, Billy will look at the signs that complexity in software development is getting out of hand, and how existing practices are not up to the task of dealing with that challenge. He doesn't pull punches; some sacred cows come in for rather severe criticism. Then he'll venture some ideas on dealing with complexity today and what changes in the industry are needed long term to counter the problem.

Fundamentalist Functional Programming - Erik Meijer

In 1984, John Hughes wrote a seminal paper "Why Functional Programming Matters" in which he eloquently explained the value of pure and lazy functional programming. Due the increasing importance of the Web and the introduction of many-core machines, in the quarter century since the appearance of the paper the problems associated with effectful imperative languages have reached a point where we hit a brick wall. We argue that fundamentalist functional programming, that is radically eliminating all side-effects from our programming languages, including strict evaluation, is what it takes to conquer the concurrency and parallelism dragon. We must embrace pure lazy functional programming "all the way," with all effects apparent in the type system of the host language using monads. Only a radical paradigm shift can save us, but does that mean that we will lose all current programmers along the way? Fortunately not! By design, LINQ is based on monadic principles. The success of LINQ proves that the world does not fear the monads.

MVC & Dynamic Data - Brad Wilson

The ASP.NET MVC framework is an exciting alternative to ASP.NET WebForms. The strength of MVC is that it gives you a clear separation of concerns, with fine-grained control over the HTML and Javascript that makes writing Web 2.0 applications much more streamlined. The ASP.NET Dynamic Data framework enables you to quickly build applications that are driven by data and business logic. In this session, Brad will preview both the ASP.NET MVC framework and the Dynamic Data implementation that's currently being developed especially to run on top of ASP.NET MVC.

I will keep a daily blog detailing my experiences at the summit.

Jean

 

 

 

Top 10 Mixes of all time

I thought I'd list my top 10 favourite house mixes of all time. I've been listening to to house, trance and hard house for a long time now so I generally have a good idea of what is going on out there... The good thing about house is that it's always changing.

1) Renaissance - Singapore : Dave Seaman

2) Global underground - San Francisco : Sasha

3) Communicate : Sasha and John Digweed

4) Friendz boat party..podcast 004 - Wynand Delport (This is a surprise 4th place a good hard house mix that gets me through most weekends... available free from the friendz website.)

5) Renaissance - Desire : Dave Seaman

6) Global underground - Cape Town : Dave Seaman

7) Gareth Emery - Essential Mix Debut 2008

8) Armin van Buuren - Essential Mix 2006-12-24

9) Eddie Halliwel - The Residency : 2006-06-04

10) Matt Hardwick -  Gatecrasher : Resident Transmission 

 Jean

Posted: Oct 23 2008, 05:35 AM by jean
Filed under:
"Nice to have" VS "Must Have"

Programmers enjoy writing code. As long as we are not under too much preassure, its always fun to add those features into the system that are "nice to have" rather than critical or "must have" features. We have become "Code Addicts". By adding all these unessesary features it allows us to play with the technology and learn from our mistakes, even if it's not at our own cost.

This is unfortunately a reality. I call to all developers there to fight their code addiction. When it gets to features, LESS IS ALWAYS MORE.

Try to find:

- The solution that involved the least amount of lines of code.

- The solution that leverages the technology in the way it is supposed to be leveraged.

- The soluton that results in a refactored whole.


Complexity results in the following:

1. Longer time periods to train up support programmer who need to support the system.

2. Greater likelihood that there are unforeseen functional bugs in the system.

3. More time is required to fix and find bugs in complex systems.

4. Non-technical staff (including management) becoming skeptical and negative towards the IT industry due to support issues.

I'm not saying that there are not times when I complex problem requires a complex solution, but we must always strive to find the shortest path through the forest.

Billy Hollis, one of my heroes will be giving a talk at the 2008 Patterns and Practices Summit in Seattle this year which I will be attending. The topic is "Drowing in Complexity". Seems like I'm not the only one aware of this problem! :-)

Jean

SubSonic vs Nettiers

I've recently been working extensively with 2 ORMS. Subsonic and Nettiers. Both really good ORMS. My favourite though without a doubt is Subsonic written and designed by Rob Connery who just coincidentally now works for the ASP.NET team at Microsoft. 

Reasons I like Subsonic:

1. Its extremely lightweight. It creates stored procedure objects that return readers or datasets.

eg.

 

    public static System.Data.DataSet GetItemTypesForClientTypeSysID(int clienttypesysid, bool bIsBatch)

    {

        StoredProcedure sp = SPs.ProcSelectItemsForClientType(clienttypesysid, bIsBatch);

        return sp.GetDataSet();

    }

 

2. You can write queries in your code that can do most things including using the SQL where / ordering and only selecting specific columns.

eg

    public static int GetClientTypeSysIDFromDesc(string clienttypedesc)

    {

 

        int tempID = 0;

        Query query = new Query(TblClientType.Schema.TableName);

        query.SelectList = TblClientType.Columns.Sysid;

        query.AddWhere(TblClientType.Columns.ClientTypeDesc, Comparison.Equals, clienttypedesc);

        query.QueryType = QueryType.Select;

        tempID = (int)query.ExecuteScalar();

        return tempID;

    }

 3. Its rediculously easy to set up. You need 1) Download the subsonic libraries, 2) Run the install so that VS will pick it up, and then 3) make an update the config file's of the projects which will be using the ORM. Obviously you need to reference the subsonic libraries also.

Reasons I like Nettiers.

1.  The documentation is pretty good.

2. Setting up nettiers is also straight forward. 1) Download the templates Codesmith Templates, 2) BUY a copy of codesmith and generate the ORM layer.

The Nettiers templates are written by the author of codesmith.... This.... in my opinion is a sales stunt although any intermediate programmer should use codesmith anyway. It's and awesome template based code generation tool.

3. You can perform DeepSave and DeepLoad actions where you are able to save and load object trees based on relational database mappings.

4. You are able to create a web services layer. With some tinkering you can expose this layer as a WCF service and thus create middle-tier DAL that is accessible using your protocol/security strategy (aka Binding) of choice.

5. Nettiers also has its own cuncurrency functionality built in assuming that all the database tables used to generate the ORM have a timestamp field.

Note: Nettiers does generate a lot of code though, and if you don't use the custom TList collection object (which doesn't lend itself well to databinding) you won't be able to deepsave and deepload. Hopefully this will be fixed in later versions of nettiers.

Jean

Passion

Passion. It's a double edged sword. It can be used to achieve your wildest dreams and goals or it can make one very self destructive.

Its that feeling you get in your chest when you listen to Beethoven's 9th symphony and the vocals kick in. Its that feeling you get when you are hill training and your whole body is aching but you enjoy the pain... It's the excitement that comes with channeling the stress at work into whatever you are doing.

We should all do our best to find our passions and when we do never let the flame burn out.

Posted: Sep 20 2008, 04:40 AM by jean
Filed under:
Removing the Tool container from the Workflowview

 I've just recently been asked to make a 'minor' change to a customized version of the WorkflowView which forms part of the System.Workflow.ComponentModel.Design namespace.

The image below highlights the ToolContainer:

 

By investigating the WorkflowView object using reflector I discovered that there was an internal field called ShowToolContainter that is hard-coded to true. See below:

 

By using  reflection you can set this property to false!! Thus removing those irritating buttons.


Type t = _workflowView.GetType();

//// Set the parent field.

t.InvokeMember("ShowToolContainer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty, null, _workflowView, new Object[] { false });

Where there is a will there is a way!! You can use this technique in future to set other internal properties which the framework does not expose.

Jean

 

 

Posted: Sep 11 2008, 02:37 AM by jean
Filed under:
Training regime - Mon - Friday
I've recently started a new training regime which has been really forcing me back into shape. One week of this regime and I could see a noticeable difference in my physique. Scary stuff.

In addition to my normal diet I am taking in:

I drink 1 protein shake a day.

8 glasses of water a day.

3 cups of rooibos or green tea a day.

2 Tins of Tuna OR 2 steaks OR 2 chicken breasts

This diet is subject to change since I have minimal time to prepare food, and my trainer(Brent) will be revising this diet over the next few weeks.

You can download the training regime here

Posted: Aug 05 2008, 06:45 AM by jean
Filed under:
Log4PostSharp : How to set it up

After an hour of banging my head against the wall and much dissapointment at the amount of documentation out there on such a usefull tool as Log4PostSharp I've decided that it would be a good idea to get off my lazy .... and write a short blog post on Log4PostSharp.

Firstly let me give you a quick description of what Log4PostSharp is: 

Log4PostSharp is an Aspect-Oriented tool that allows you to log when a

1) method is entered

2) method is exited

3) when a method throws an exception

Methods that you would like to implement this logging functionality on, only have to be decorated by a Log attribute from the Log4PostSharp namespace.

 
Steps to set up An application to use Log4PostSharp:

1) Download the source code for the Log4Post sharp project from http://postsharp-user-plugins.googlecode.com/svn/trunk/Log4PostSharp/

2) Optionally you can compile the project in VS2008 - There is a \Libraries folder that contains all though if you are still stuck with VS 2005 (like the 95% of the working population :-) )

3) Download and install the PostSharp Aspect Oriented tool from http://www.postsharp.org/.

4) Copy Log4PostSharp.psplugin and Log4PostSharp.Weaver.dll from the Libraries folder in the Log4PostSharp project into the plugins folder created by the PostSharp installation which would normally be at C:\Program Files\PostSharp 1.0\PlugIns

5)  Then in your project: Add references to the following libraries : log4net.dll (from the log4net project) + log4PostSharp.dll (from the log4postsharp project) + PostSharp.Public.dll (from the PostSharp project)

6)  Update your AssemblyInfo.cs file with:

 

[assembly: Log(AttributeTargetTypes = "*", EntryLevel = LogLevel.Debug, ExitLevel = LogLevel.Debug, ExceptionLevel = LogLevel.Error)]

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4PostSharpTest.exe.log4net.config", Watch = true)]

As you can see Log4PostSharpTest.exe.log4net.config is the name of the config file that will hold the log4net configuration settings. 

7) Create a configuration file Log4PostSharpTest.exe.log4net.config and insert the log4net configuration settings: eg

 <?xml version="1.0" encoding="utf-8" ?>

<log4net>

     <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

           <param name="File" value="trace.log" />

           <param name="AppendToFile" value="true" />

           <param name="MaxSizeRollBackups" value="5" />

           <param name="MaximumFileSize" value="100KB" />

           <param name="RollingStyle" value="Size" />

           <param name="StaticLogFileName" value="true" />

           <layout type="log4net.Layout.PatternLayout,log4net">

                <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />

           </layout>

     </appender>

     <root>

           <level value="DEBUG" />

           <appender-ref ref="RollingLogFileAppender" />

     </root>

</log4net>

 8) Finally decorate the methods in your application that you would like to treack with the logging functionality by using the log attribute as mentioned earlier eg:

 

        [Log(EntryLevel = LogLevel.Debug, EntryText = "Test for '{@i1}', '{@i2}', '{@r1}', '{@r2}'.")]

        [Log(ExitLevel = LogLevel.Fatal, ExitText = "Was called with params: {paramvalues}.")]

        [Log(ExceptionLevel = LogLevel.Fatal, ExceptionText = "Exception occured with parameters : '{@i1}', '{@i2}', '{@r1}', '{@r2}'.")]

9) Run the application and have a look at the magic in the trace.log file output. Since I had my debug setting set to DEBUG, every every event handled by the log4postsharp framework was logged. 

So my output looked like:

2008-07-24 15:49:32,726 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: Void Main(System.String[]).
2008-07-24 15:49:32,757 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: Void MethodWithNoReturnValue().
2008-07-24 15:49:32,757 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: Void MethodWithNoReturnValue().
2008-07-24 15:49:32,757 [1] FATAL Log4PostSharpTest.Program [(null)] - Calling eebd09aa-c47c-4f2e-a21e-e90d8030ed6a.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: Void MethodWithNoReturnValue(System.Guid).
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: Void MethodWithNoReturnValue(System.Guid).
2008-07-24 15:49:32,773 [1] FATAL Log4PostSharpTest.Program [(null)] - Return value is: ''.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Test for '1', 'A', '10', 'X'.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: Int32 MultipleArgsMethod(Int32, System.String, Int32 ByRef, System.Object ByRef, System.Guid ByRef, System.String ByRef).
2008-07-24 15:49:32,773 [1] FATAL Log4PostSharpTest.Program [(null)] - Return value is: '51'.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: Int32 MultipleArgsMethod(Int32, System.String, Int32 ByRef, System.Object ByRef, System.Guid ByRef, System.String ByRef).
2008-07-24 15:49:32,773 [1] FATAL Log4PostSharpTest.Program [(null)] - Was called with params: "1", "A", "10", "X", "6fef8a16-9373-490c-bf07-3d47feda5c31", "X".
2008-07-24 15:49:32,773 [1] INFO  Log4PostSharpTest.Program [(null)] - Test message.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: System.Guid MethodWithGuidReturnValue().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: System.Guid MethodWithGuidReturnValue().
2008-07-24 15:49:32,773 [1] INFO  Log4PostSharpTest.Program [(null)] - Doing stuff.
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Entering method: Int32 MethodWithIntReturnValue().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: Int32 MethodWithIntReturnValue().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Entering method: Void .cctor().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Exiting method: Void .cctor().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Entering method: Void .ctor().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Exiting method: Void .ctor().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Entering method: U Act[U]().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program+AnotherSubprogram`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] [(null)] - Exiting method: U Act[U]().
2008-07-24 15:49:32,773 [1] DEBUG Log4PostSharpTest.Program [(null)] - Exiting method: Void Main(System.String[]).
 

Additional information and references:

- http://www.postsharp.org/

- http://postsharp-user-plugins.googlecode.com/svn/wiki/Log4PostSharp.wiki

- http://www.postsharp.org/forum/log4postsharp/

- http://haacked.com/archive/2006/08/08/Log4NetAndExternalConfigurationFileInASP.NET2.0.aspx

- http://code.google.com/p/postsharp-user-plugins/wiki/Log4PostSharp

 
And finally a big thank you to PostSharp for the AOP tool and especially Michal Dabrowski for writing the Log4PostSharp addin. Thanks also to my boss Eden that introduced me to this tool.

I'll be updating this post with more information in the near future. You can either follow the instructions above or you can download my Test application from here.

Happy coding.
Jean

 


 

More Posts Next page »