Recently I’ve found a method GeneratePassword() in the good old .NET full framework, in the System.Web.Security-namespace. It has two parameters to specify the complexity of the password.
public static string GeneratePassword (int length, int numberOfNonAlphanumericCharacters);