Virtual Machine Installation Checklist

A quick checklist. Mostly just for me.

  1. Install guest.
  2. Create descriptive wallpaper (root chain).
  3. Install guest tools.
  4. Change WSUS server.
  5. Update Windows.
  6. Bootstrap Internet Explorer.
  7. Install Clamwin.
  8. Update Clamwin.
  9. Change registered company to my company. Remember WOW64 node.
  10. Disable netlogon machine password change.
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange = 1
  11. Disable shutdown event tracker.
  12. (Snapshot)
  13. Create descriptive wallpaper (development chain).
  14. Join domain.
  15. Install .Net Framework 3.51.
  16. Install IIS.
  17. Install MSMQ AD Integration.
  18. Install Visual Studio.
  19. Install TFS Client.
  20. Install Visual Studio SP1.
  21. Install SQL Server.
  22. Install SQL Server SP1.
  23. Configure SQL Firewall Ports.
  24. Enable SQL Server TCP/IP.
  25. Install GhostDoc.
  26. Install CodeRush.
  27. Install Coco/R.
  28. Install Tytan.
  29. Update Windows.
  30. Bootstrap VS.
  31. Apply VS customizations.
    1. Import settings.
    2. Set up TFS working folder.
    3. Set up GhostDoc to use langword.
  32. Bootstrap SMS.
  33. Create link to K2 keygen.
  34. (Snapshot)
  35. Justice.
Posted in Software, Virtualization | Leave a comment

Code Contracts

I have recently started using the Microsoft CodeContracts on a large scale. These have been a fantastic addition to my toolset; because when I get the green flag on my code I know that I am pretty safe (it is beta, after all). I had to migrate quite a bit of code into the contracts and found that it can be quite a daunting task. A few things that I have picked up are:

  • If you are migrating existing code and worrying only about contracts, switch off background checking. Firstly, this means that the results you get are comprehensive and secondly because of the build time you will think twice about hitting that build key again. Long builds == fewer builds == more time thinking == better code.
  • Use code snippets. The ones provided by Microsoft are great! Think about creating your own or changing them. For example cren and cresn no longer throw ArgumentExceptions for me; they are both ArgumentNullExceptions. I also have snippets like create contract class for (cc – scaffolding for ContractClassFor) and contract class implementation (cci – ContractClass attributation).
  • Invariants are your friend. Figure out what state a class should really be in and depend on that rather than Contract.Requires everywhere.
  • A well placed Contract.Ensures will save you a lot of grief.
  • Don’t loose hope. It may seem like it’s daunting at first – but as you start thinking in terms of contracts things become a lot faster. A single well-thought out Contract call will often clear off 5 warnings (for the bigger projects).
  • Some classes can be skipped ([ContractVerification(false)]) – especially if they are internal. Don’t gung-ho and try and get everything in contracts; because sometimes they may be ill-suited for the task (and you would by ‘lying’ just to get the stuff to pass). These situations are few and far between; but they are there.
  • New development = contracts. Full stop.

Overall I am finding fewer and fewer Contract failures during each build. This is mainly because CodeContracts is getting me into a better and more disciplined mindset. It’s a great tool and I highly recommend it.

Posted in Best Practices, C#, Short, XMPP Server 2010 | Leave a comment

Code Block Toggler

I came across one of the most awesome meta-language features for C-style languages (specifically any language that has /* */ and // comment support). The nitty-gritties are up at a rather good blog. I whipped up a snippet to handle this automatically.

It has a few notable features – it gives a reason for the flip, it wraps it in a region, it has a auto-task FLIP: prefix and it explains how it’s used.

            #region Flip - This new behaviour is experimental. -
            // FLIP: This new behaviour is experimental.
            //*/// Two proceding slashes will activate the first block, one will activate the second.
            Console.ReadLine();
            /*/
            Console.ReadLine();
            //*/
            #endregion Flip - This new behaviour is experimental. -

Drop it in your My Code Snippets folder. In VS select the code you want to flip-comment, Hold CTRL, Press K, Press S, Release CTRL, Press M, Press Enter, Press F, Press Enter (I wish you could assign hot keys to snippets!).

Code Block Flipper (WordPress won’t let me upload .snippet – so you will need to rename it)

Posted in Programming, Top Hacks, Tricks | Leave a comment

Automatically Wrap BeginInvoke (dispatch)

C# supports implicit/explicit conversions to Delegates.

Yes, big news. I was very surprised when I gave this a shot. It’s really just one of those things you really don’t expect to work. So how does this help us? I am sure you are quite sick of writing the following code (the same stuff applies to WPF, you just need to access it via the Dispatch member):

void _items_CollectionChanged(object sender, CollectionChangedEventArgs<ConnectionListItem> e)
{
    if (InvokeRequired)
    {
        Invoke(new EventHandler<CollectionChangedEventArgs<ConnectionListItem>>( _items_CollectionChanged ), sender, e);
        return;
    }

}

The ‘big news’ allows us to do all the heavy lifting for the dispatch BeginInvoke in one simple class (this is a first try – I’ll get round to reviewing it later on).

    /// <summary>
    /// Represent a wrapper for a delegate.
    /// </summary>
    /// <typeparam name="T">The type of event args.</typeparam>
    public class InvokeEventWrapper<T>
        where T : EventArgs
    {
        private EventHandler<T> _apparantHandler;
        private EventHandler<T> _rawHandler;
        private Control _parent;

        /// <summary>
        /// Initializes a new instance of the <see cref="InvokeDelegateWrapper<T>"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="handler">The handler.</param>
        public InvokeEventWrapper(EventHandler<T> handler)
            : this(null, handler)
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InvokeDelegateWrapper<T>"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="handler">The handler.</param>
        public InvokeEventWrapper(Control parent, EventHandler<T> handler)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            if (parent == null)
                parent = (Control)handler.Target;

            _parent = parent;
            _rawHandler = handler;
            _apparantHandler = new EventHandler<T>(Raise);
        }

        /// <summary>
        /// Performs an implicit conversion from <see cref="SharedTerminals.InvokeDelegateWrapper<T>"/> to <see cref="System.EventHandler<T>"/>.
        /// </summary>
        /// <param name="wrapper">The wrapper.</param>
        /// <returns>The result of the conversion.</returns>
        public static implicit operator EventHandler<T>(InvokeEventWrapper<T> wrapper)
        {
            return wrapper._apparantHandler;
        }

        /// <summary>
        /// Raises the event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void Raise(object sender, T e)
        {
            if (_parent.InvokeRequired)
                _parent.BeginInvoke(_rawHandler, sender, e);
            else
                _rawHandler(sender, e);
        }
    }

Using it is pretty simple:

  1. Navigate to the event in Intellisense.
  2. Type +=.
  3. Press Tab.
  4. Replace EventHandler with InvokeEventWrapper.

So in the end all of that ugly code becomes:

_items.CollectionChanged += new InvokeEventWrapper<CollectionChangedEventArgs<ConnectionListItem>>( _items_CollectionChanged );

You will need to hold onto a reference for that wrapper if you wish to unsubscribe from the event (one of the things I need to look at).

Posted in C#, Programming, Tricks | Leave a comment

SSRS Timeout on SSL 443 – Resolved

Manifestation of the Error

If you attempt to connect to SSRS via the deployment webservice; when SSRS is running in SSL mode (specifically on port 443), you may get one of the following exceptions (which do not occur intermittently):

  • The underlying connection was closed: An unexpected error occurred on a send.
  • The operation has timed-out.

You might get it for other “The underlying connection was closed” errors, but I have not confirmed that. The issue occurs mainly when you try to upload report definitions that are over approximately 100kb.

The Solution

Let me tell you straight up – there is no reason to disable SSL or alter timeouts. The first thing you want to do is to add a new class to your project; I called mine SslReportService. Implement ReportingService2005 from your WebService reference. You can then override GetWebRequest(Uri) without worrying about your changes being lost of you update your web reference.

Then, in a nutshell:

class SslReportService : ReportService.ReportingService2005
{
  protected override System.Net.WebRequest GetWebRequest(Uri uri)
  {
    var res = (HttpWebRequest)base.GetWebRequest(uri);
    res.SendChunked = true;
    return res;
  }
}

Your mileage may vary; so if this turns up nothing Engels Rajangam has another helpful post on this issue. You might want to read up on this property on MSDN and a pretty good blog post.

Posted in C#, Programming, SSRS | 2 Comments

Direct to MSDN Chrome Search Tag

If you ever need to get directly to the documentation for a specific type in MSDN (which Bing routinely fails to give me) here is a search provider for Chrome that will do the trick:

http://msdn.microsoft.com/en-us/library/%s.aspx

You can obviously also do something like:

http://msdn.microsoft.com/en-us/library/%s(loband).aspx

In case you need a refresher, here is how you add it:

  1. Click the wrench (top right).
  2. Options
  3. Basics (top)
  4. Manage (alongside “Default Search”)
  5. Add
  6. Give it a name and keyword (the keyword is important).
  7. Paste in my URL.

To use it go to your address bar and type the keyword, tab and then the full type name. So for example (my keyword was msdnd):

msdnd : [TAB] : system.xml.serialization.xmlelementattribute : [RETURN]
Posted in Chrome, Programming, Short, Tricks | 2 Comments

XLinQ Serialization

Just found out that Microsoft actually had the foresight to support the following scenario:

/// <summary>
/// Gets the unknown elements as a <see cref="List{XElement}"/>.
/// </summary>
[XmlAnyElement]
public List<XElement> UnknownElements
{
    get;
    set;
}

Fantastic (undocumented) news.

Posted in C#, Programming, Short | 1 Comment

Constructive RTFM

I present to you, an improvement on support ticket forms:

New Support Request Form

New Support Request Form

“You need massive cajones to put that up!” I hear you say, but hear me out.

Firstly there is the obvious advantage of users realising that there is, in actual fact, documentation available that will assist them with simple things like this. Notice the inline help even at this point – some users might not use the documentation because they don’t know how to reach it.

You now have a compounded situation. If the user actually decides to click the submit button with a reason and the validation passes (140 characters minimum is probably a good bet) you really do have a problem – they did RTFM and got no answers. In this situation you have already solved your problem; you now know what areas of your documentation you need to address. The next customer who comes across this page with the same problem won’t be submitting a ticket.

You could always even provide a group of radio buttons so that the user has quick answers – and at the same time you will have data that can be graphed.

It is important to remember – you are not being rude at all. Referring to the documentation will mean that the turnaround time for an answer will be orders of magnitudes faster than relying on a limited amount of human resources.

Posted in Brutal, Ideas | 1 Comment

TFS Server 2008 – Fail

It’s an amazing server. The installer needs A LOT of work. Here is what happened to me:

  1. Followed the pre-setup instructions to the T.
  2. Run the installer; health check fails. SQL Server is the wrong version (2008 RTM); can’t find analysis services, NOTHING.
  3. Hmm… must need SQL 2008 SP1. Install it via Windows Update.
  4. Try again; health check fails. Wrong version of SQL Server, again.
  5. Google – get a solution.
  6. Follow those instructions to the T.
  7. Installer CRASHES. Each time it does this I need to reboot.
  8. Eventually just delete the SQL Server version check from hcpackages.xml
  9. It looks like it’s installing now.

16 hours later. TFS Server 2005 took me merely 4-5 hours (did it twice). Considering it’s a test-bed server where I am going to continue working on integrating K2 with TFS Server (we are going to be using K2 to automate our builds) this was just plain ridiculous.

It’s clever, and that’s about it, to use Sharepoint. It seems as though TFS might have started off as a Sharepoint extensibility test. Things would be far easier were it not for the whole Sharepoint dependency (and analysis and reporting – I don’t need this).

These guys need to take a hint from the ASP.net team.

Posted in Fail, K2, Software, TFS Server | Leave a comment

VMWare vSphere Client Under Windows 7

This is a patch to get the client tools working.

  1. Extract it over VMWare folder in Program Files which should be one of:
    • C:\Program Files\VMWare
    • C:\Program Files (x86)\VMware
  2. Update each shortcut by:
    1. Right click the shortcut.
    2. Click properties.
    3. Click Shortcut (at the top).
    4. In the target box change the .exe at the end to .cmd
    5. Click Ok.

VMWare vSphere Client Patch

Clearly, I take no responsibility for any ill effects that this patch may cause – whatsoever.

Posted in Software, VMWare, Windows 7 | 3 Comments