Archive for August, 2008

How to Create The Ultimate Windows XP Installation CD/DVD

August 5th, 2008

http://www.anewmorning.com/2008/01/30/how-to-create-the-ultimate-windows-xp-installation-cddvd/

My laptop is in the perfect condition to try this out – fresh install with all the base apps ready to go.

MCMS: GetByGuid throws COMException (“Server Error”)

August 5th, 2008

In (the now famous) Project P, working with Microsoft CMS’s security model had me ripping my hair out.

Whenever I made a call to the context.Searches.GetByGuid() method, the system would throw a COMException, citing the quite unhelpful message “Server Error. Please contact your administrator”

For future reference (in case anyone comes across this themselves) the problem was caused because the GUID i was passing into the application was not formatted in the correctly for what CMS was expecting.

My code was doing:
string inputGuid = myGuid.ToString();

But it turns out it actually needed to be:
string inputGuid = myGuid.ToString(“B”);

The difference (according to MSDN) is that .ToString() with no overload assumes the format identifier of “D” which results in a GUID formatted without curly braces. Format “B” provides the same guid string but with curly braces.

Why this needed to throw a “Server error” exception, is beyond me. A simple ArgumentException would have sufficed, or better still it could take in a Guid as the parameter instead of a string.

For a blow-by-blow account of this problem, visit my newsgroup post about UserHasRightToBrowse Always Returns True

Covariance and Contravariance

August 4th, 2008

Covariance and Contravariance are terms used in programming languages and set theory to define the behaviour of parameter and return types of a function.

Yes, that’s a mouthful, but in a nutshell:

  • Covariance mandates that the return type and the parameters of a function must be a subtype of the original base class type for any superclass
  • Contravariance allows the return type and/or the parameter types to be super-types of the defined types and not necessarily sub-types

Nothing better than using an example:

   1:  public abstract class Animal
   2:  {
   3:      Animal CreateChild();
   4:  }
   5:   
   6:  public class Human : Animal
   7:  {
   8:      Animal CreateChild( return new Human(); }
   9:  }
  10:   
  11:  public class Dog : Animal
  12:  {
  13:      Dog CreateChild( return new Dog(); }
  14:  }

In this example:

  • Animal is a superclass.
  • Human is a subclass of Animal, with a covariant (no change) override to the CreateChild method to return the looser type Animal
  • Dog is a subclass of Animal, with a contravariant override to the CreateChild method to return the stronger type Dog

More reading on Eric Lippert’s blog series on Covariance and Contravariance in C#

EDIT: I thought it best prudent that I clarify that this is only one example of where variance is used. Method signatures, delegates and arrays are some more examples of where the theory of co and contra variance can be found.

For everything else, there’s …

August 3rd, 2008

Dual booting Linux and Windows – Free
Resizing Windows partition into adjacent free space – Free
Realising that activating second primary partition, has wiped partition table – Priceless
For some things, you deserve a kick in the head. For everything else, there’s data recovery.

As you might have guessed, i’ve lost a lot of time at this point, and some data, though fortunately a fair bit was recoverable. What i did lose (and really peeves me) was my development Virtual Machines, with VS/SQL/IIS all configured and ready…Now to go through the long process of rebuilding VMs.