Displaying Contacts in Microsoft Outlook Address Book

December 4th, 2007

If you can’t get your contact list coming up in Outlook, here’s a how-to that works well. Two things to look out for are Outlook not closing properly (it may run as a notification button, open Task Manager and kill the Outlook process off just to make sure) which seems to stop the fix from working, and the fact that right-clicking on the Outlook icon to get to mail settings doesn’t work if the Outlook icon is a shortcut (ie 99% of the time). To get into mail settings, open Control Panel then Mail once Outlook is shut down.

isalegendinalunchbox.com registered

October 14th, 2007

I registered isalegendinalunchbox.com this morning. It’s going to be a fan club hub :-D as in paulyshore.isalegendinalunchbox.com and thetodd.isalegendinalunchbox.com. lol I kill myself.

Fine-tuning polymorphism in C# using the new keyword

August 8th, 2007

This doesn’t come up too often but can be useful. Sometimes, when using inheritance, it can be difficult to get the right implementation of a virtual method called. This is the kind of model I had today:

namespace InheritanceTest
{

	public class BaseClass
	{
		public BaseClass() {}

		public virtual void A(int count)
		{
			for (int i = 0; i < count; i++)
				B(string.Format("{0} Base Hello", i));	// This calls DerivedClass.B(string)
		}

		public virtual void B(string s)
		{
			Console.WriteLine("Base: "+s);
		}
	}

	public class DerivedClass : BaseClass
	{
		public DerivedClass() : base() {}

		public override void A(int count)
		{
			base.A(count);	// call BaseClass.A(int)
		}

		public override void B(string s)
		{
			Console.WriteLine("Derived: "+s);
		}
	}

	class MainClass
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("Test begins:");

			DerivedClass obj = new DerivedClass();
			//obj.B(10);

			Console.WriteLine("Test ends.");
		}
	}
}

When this is compiled and run, the method called in BaseClass.A() is DerivedClass’s implementation of B(). The series of method calls will look like this:

  1. DerivedClass.A()
  2. BaseClass.A()
  3. DerivedClass.B() ten times

So when BaseClass.A() makes the call to B(), the derived class’s B() method is found and executed, rather than BaseClass.B(). This is exactly how you would usually want the inheritance to work; the derived class has methods that override the base class, and the base class calls fall through to the child’s implementation of the virtual methods.

The problem with this is if you want to be able to use the base class’s implementation of B() in BaseClass.A()’s call to B(). BaseClass.B()’s implementation may contain code required in BaseClass, but DerivedClass.B()’s implementation is not appropriate for use in BaseClass. Basically you want the following series of method calls:

  1. DerivedClass.A()
  2. BaseClass.A()
  3. BaseClass.B() ten times

We need to indicate to the compiler that, although DerivedClass.B() implements B(), it doesn’t necessarily override BaseClass’s implementation of B(). That is done by changing the override keyword in DerivedClass.B()’s declaration to new:

Change:
   public override void B(string s)
to:
   public new void B(string s)

The effect of this is that when B() is called in BaseClass, it will be BaseClass.B() that will be executed, because DerivedClass.B() is flagged as a new implementation of the B() method that does not override the existing one. The new DerivedClass.B() method is still visible in DerivedClass and beyond:

DerivedClass obj = new DerivedClass();
obj.B("Test");   // This will execute DerivedClass.B(), not BaseClass.B()

will execute DerivedClass.B().

Causeway Lake Boat Hire site update

July 24th, 2007

I’ve just finished off some changes to Causeway Lake Boat Hire’s website. They’ve just introducted boat licensing and training so I’ve added a new page and played with the layout a touch. This was another of my very early sites which I reimplemented in XHTML and currently host.

July 24th, 2007

dsc_2870.JPG dsc_3261.JPG

Better photo of Cameron and Sian-lee

July 16th, 2007

As claimed, here is a photo of Cameron & Sian-lee at our wedding where S. doesn’t look like she sucked a bubble up her nose:

Cameron & Sian-lee

Security error when impersonating a user in an ASP.NET application

July 12th, 2007

I was trying to get security impersonation working in an ASP.NET app so that database access would work correctly. For reference, to impersonate a user, add this to the web.config file:

The password is stored in plain text format, this is a bit scary but that looks like the way to do it. There must also be a way of using IIS to do the impersonation but I couldn’t get that up.

Now that the app is impersonating the MyDatabaseUser account, it no longer has access rights to the temporary ASP.NET folder. This gives a yellow screen of death with the following error:

Access to the path "C:\\Windows\\Microsoft.NET\\Framework\\v1.1.4322\\Temporary ASP.NET Files\\MyApplication\\XXXX\\XXXX\\hash.web" is denied.

To resolve this, the account needs to be given write permission to the temporary folder. Browse to "C:\[windows]\Microsoft.NET\Framework\[.net version]", open properties for the Temporary ASP.NET Files folder and go the Security tab. Add your database user account and give it the same permissions as the NETWORK SERVICE user (full control). Once this is applied the user (and therefore the application) will have access to the temporary folder root. Now you can move on to the next YSOD.

Die, robots, die!

July 7th, 2007

die robots die

Aussie Tender Centre website touchup

July 6th, 2007

I’ve just finished up some changes to a site I developed about four years ago - the Aussie Tender Centre. This was the first commercial site I ever worked on, and it’s been running almost constantly, with very few issues and quite a bit of traffic. Check out the Virtual Tour link on the top menu bar - David (the manager) gives me a little plug :-D

Breakfast

May 31st, 2007

Carrie got me this great little espresso cup yesterday and this morning I made a macchiato. It was good :-D

My breakfast macchiato