Virtual (and Free) Visaul Basic.Net Programmer's Cookbook

This is a very useful reference because of the problem/solution format that it employs to present the Visual Basic.Net language. However, I’m waiting for Microsoft Press to re-publish it for VB.Net 2005 before I buy a copy. Until then, I’ve discovered that you can download the complete source code for all examples in the book from Microsoft Press. After downloading the solutions and source code to your local computer, you can use the online table of contents to find the solutions you are looking for.

Implementing Dispose()

A best practice when you create a classthat uses unmanaged resources is to implement the Dispose() method of the IDisposable interface. Even if your class is not using unmanaged resources directly but contains members that do (i.e. ADO.Net objects), it’s a good idea to implement Dispose() to call Dispose() on those members.

In order to properly implement Dispose(), you have to follow some rules. You can find an example of how to go about this in this MSDN library article on implementing Dispose() and Finalize().

Trouble Writing to the Event Log from ASP.Net?

This Microsoft KB article offers some work arounds.

You’re not alone. The ASP.Net worker process account doesn’t have permission to create a new event log source. This Microsoft KB article offers some work arounds.

I’ve also had this same problem with Windows Service applications that try to write to the event log, so it would seem that the local service account doesn’t have permission to create an event source either (eventhough writing to the event log is such a common function of Windows Services that it is used as an example in the otherwise helpful tutorial from Microsoft!). Although I came up with another solution at that time (runing the code to write to the log once from a command line project while logged in as a user with the proper permissions), I’m sure the solutions in the above article would work, too.

.Net Date Format Strings

I keep forgetting these and not being able to find them in the MSDN library without going through pages of locailzation jargon, so I’ve decided to reprint this list that I found on

  • d – Short date
  • %d – Day number
  • M?d – Month and day number
  • dd – Day number, two digits
  • ddd – Abbreviated day name
  • dddd – Full day name
  • f – Full (long date, short time)
  • %f – Fractions of second, one digit
  • s^f – Seconds and fractions of second, one digit
  • ff – Fractions of second, two digits
  • fff – Fractions of second, three digits
  • ffff – Fractions of second, four digits
  • fffff – Fractions of second, five digits
  • ffffff – Fractions of second, six digits
  • fffffff – Fractions of second, seven digits
  • g – General
  • %g – Era (eg. A.D.)
  • y-g – Year and era (eg. 5-A.D.)
  • gg – Era (eg. A.D.)
  • h – Hour (1-12) (Doesn’t seem to work)
  • %h – Hour (1-12)
  • h-m – Hour and minute
  • hh – Hour (01-12)
  • H – Hour (0-23) (Doesn’t seem to work)
  • HH – Hour (00-23)
  • m – Month name and date
  • %m – Minute (0-59)
  • hh_m – Hour and minute (0-59)
  • mm – Minute (00-59)
  • M – Month name and date
  • %M – Month number (1-12)
  • M+d – Month number and day number
  • MM – Month number (01-12)
  • MMM – Month abbreviation
  • MMMM – Month name
  • s – Standard sortable date/time
  • %s – Seconds (0-59)
  • s^ff – Seconds (0-59) and fraction of seconds
  • ss – Seconds (00-59)
  • t – Long time
  • %t – First letter of AM/PM designator
  • hh+t – Hour and first letter of AM/PM designator
  • tt – AM/PM designator
  • y – Short date
  • %y – Year (0-99)
  • m-y – Month and year
  • yy – Year (00-99)
  • yyyy – Year (0000-9999)
  • z – Doesn’t work
  • %z – Whole hour time zone (-12 to +13)
  • Zone:z – Zone – and whole hour time zone (-12 to +13)
  • zz – Whole hour time zone (-12 to +13) with two digits
  • zzz – Time zone in hours and minutes})

Remove Unwanted Projects from the Visual Studio Recent Projects List

How to remove unwanted projects from Visual Studio recent project lists.

The Visual Studio development team doesn’t seem to realize that people sometimes open a project with the same name as another. I say this because they don’t provide a way for users to remove projects from the recently opened project list. This can be particularly irksome if, for example, you normally only work on the development version of a project but you open the production version once and from that point on you have two identical project names in the list.

Until they incldue this function in visual studio, if you’re using VS.Net 2003 you can download Laudeci Oliveira’s
VS Recent Project List Cleaner
, which removes recent project list entries from your registry. For the beta versions of VS 2005 (Whidbey), it’s even easier to get rid of unwanted projects – just delete them from the “My Documents\Visual Studio 2005\Projects” folder.