Very useful .NET debugging aid

The following can be very useful when debugging a service or any other .NET app

At an appropriate point in your code you add:

if ( !System.Diagnostics.Debugger.IsAttached )

It will search for a suitable debugger which would include the IDE that you have open on your code.

Replacement for ShellExecute

Try using:


This is much cleaner than the PInvoke version of:

public static extern int ShellExecute(IntPtr hWnd,
            string lpszOp, string lpszFile,
            string lpszParams, string lpszDir,int FsShowCmd);

static void Main(string[] args)
int hWnd;
long noth;

ShellExecute(0, “OPEN”, @”D:\WINNT\NOTEPAD.EXE”,
null, null, 0);



System.Net contains the ever useful WebClient class.

This allows code such as:

System.Net.WebClient wc = new System.Net.WebClient();
byte[] myDataBuffer = wc.DownloadData(url);
string download = System.Text.Encoding.ASCII.GetString(myDataBuffer);

This allows the text at a given url to be extracted.
Welcome to your own web spider.