My Software : Comments and observations related to the usage and installation of softwares on my systems.
Updated: 2007-02-01; 08:49:12.

 

Subscribe to "My Software" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.


Categories: (Check them too. My content isn't all on the main page)

Knowledge Management
Technology
My Hardware
My Software
En français!
Top 20 topics!


Currently reading:

The Second World War, Volume 1: The Gathering Storm by Winston S. Churchill

Beginning Linux Programming (Programmer to Programmer) by Richard Stones and Neil Matthew



www.blogwise.com

Male/31-35. Lives in Canada/Ontario/Ottawa/Manor Park, speaks French and English. Spends 80% of daytime online. Uses a Faster (1M+) connection. And likes Cooking/Reading.
This is my blogchalk:
Canada, Ontario, Ottawa, manor Park, French, English, Male, 31-35, Cooking, Reading.


The Political Compass: Economic Left/Right: -3.50
Authoritarian/ Libertarian:
-2.26


Technorati Profile
Popdex Citations



 
 

23 février 2003


Sairama's Interesting Code of the Day - Printing Line Numbers while Debugging C#.

In C++ if problems happen, we'll want to log the error along with filename and Line Numbers, often like:

CString strCompleteMessage;
strCompleteMessage.Format(_T("%s , HRESULT %0x [%s,%d]"),strMessage,hr,A2W(__FILE__),__LINE__);
LogInfo(strCompleteMessage);

In C#, there are no such macros so we use the StackFrame class. Below we show how to print the filename and line numbers while logging messages/errors.

     public static void foo()
     {
     // some operations here
     // some error here
     string msg = "Unable to do xyz operation, Please report this to abc@xyz.com";

     // true means get the file information also ( needs pdb files which can be generated for Release builds )

     StackFrame CallStack = new StackFrame(0, true);
     Console.WriteLine("Error:{0} occurred in:{1} in File: {2} at Line: {3}", msg, CallStack.GetMethod(), CallStack.GetFileName(), CallStack.GetFileLineNumber() );
}

[Scott Hanselman's Weblog]

Pretty nice trick!

6:28:39 PM    comment []  - See Also:  Programming Micro$oft 


QQQ is sending out an SOS.

Thomas Marquardt, one of our developers on ASP.NET, recently published an article on MSDN about ASP.NET performance monitoring.  Along with the article are a number of great utilities (all complete with C# source code). 

We developed them internally to help automate diagnosing customer issues with production apps, and they are also used as part of our ASP.NET stress testing program (I'll provide more details about our stress lab in a future blog entry).  These source utilities include:

Snap.exe -- a command-line tool for logging performance data for processes.

HttpClient.exe -- a simple client that records time to last byte (TTLB) for HTTP requests.

ErrorHandler.dll. This is an IHttpModule that you can add to the HTTP pipeline to log unhandled exceptions to the event log. It is better to log errors to a SQL Server database (that is what we do in our stress lab -- since it makes reporting across hundreds of servers easier), but the example uses the event log for simplicity.

QQQ.exe -- a command-line tool for stress testing an ASP.NET application. When used in combination with a stress client, such as Homer or ACT, this tool will attach debuggers to the worker process and monitor certain performance counters.  It can be tuned to automatically break into the debuggers when performance degrades.

QQQ is probably my favorite utility -- especially given that its name is complete nonsense.  "QQQ" stemmed from the fact that Dmitry (ASP.NET dev manager) likes to name all of his test ASP.NET pages with those initials, usually under various temporary directories scattered accross his harddrive.

QQQ is usually used in combination with the windbg and cdb debuggers (which you can download from: http://www.microsoft.com/ddk/debugging/installx86.asp).  These debuggers are more appropriate for system level dubugging (versus the VS debugger) in that they have less effect on the process they are attached to (unlike the VS debugger which tends to impact timings within the target process -- making stress investigations harder).

QQQ is also typically used in conjunction with a .NET Framework debugger extension we call "sos.dll".  Strike.dll was the parent debugger extension we used in V1 of the .NET Framework -- "sos.dll" affectionately stands for "son of strike".  You can download son of strike at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/DBGch03.asp.

If you are doing hard-core production ASP.NET development, and want to build up an infrastructure for testing and monitoring your web applications, then I'd definitely recommend spending an hour browsing through the above code.  There are a lot of cool tips/tricks you can pick up and re-use.

Quick Update: A few people have pinged me as to how they can get the source to the above utilities.  Note that a link to them is in the top article above.  The direct url is: http://download.microsoft.com/download/3/c/8/3c820668-3095-40e2-b462-0bc8a0b6690f/monitoring_tools.exe

[ScottGu's Blog]

Can be useful while debugging asp.net

6:02:58 PM    comment []  - See Also:  Programming Micro$oft 

© Copyright 2007 Charles Nadeau.



Click here to visit the Radio UserLand website.
 



-->
February 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28  
Jan   Mar


Google
Search the whole web!
Search Charles radio!


www.flickr.com


Top 5 artists I listen to the most often during the last week:


I subscribe to:

Here's how this works.


Weather in Ottawa:
The WeatherPixie
Weather in Fukuoka:
The WeatherPixie