• Code analysis without buying Visual Studio Team System

    If you download the Microsoft® Windows® Software Development Kit (SDK) for Beta 2 of Windows Vista and WinFX Runtime Components, then you actually get the C++ compiler that includes support for the “preFAST” /analyze code analysis feature.

    Normally, you’d only get this if you purchased Visual Studio Team System for lots of $$$.

    I installed it, and managed to get Mozilla Firefox compiled (just a couple of patches required - problems with the new headers in the SDK conflicting with Mozilla code).

    The easiest way to analyze the code is to edit your mozconfig file and add the following:

    ac_add_options --enable-optimize="-analyze"

    I’ve uploaded a build log that includes the various warnings. Many are spurious, so the trick is to weed out the noise and find the ones that are relevant.

  • Customising Visual Studio.NET 2005 for Single and Dual Monitors

    I have been using a dual-monitor setup for a couple of years now, and find it a very practial way to develop.

    I also work from home, and use Remote Desktop (RDP) to connect back to my workstation at work. The problem is that RDP only works on a single screen - so when you launch Visual Studio, all the windows that were anchored on the second screen now are messed up.

    The solution is to use the Import and Export Settings wizard to save two window layouts - one for a single screen and one for a dual screen. You can then load these settings to reset the window layout for the appropriate monitor.

    To automate the process even further, you can create some Visual Studio Macros and assign them to a custom toolbar so that you can do it all with a single click of your mouse.

    Here’s my macro code that loads the two different window settings:

    Sub RDPLayout()

        DTE.ExecuteCommand(“Tools.ImportandExportSettings”, “/import:”“U:\My Documents\Visual Studio 2005\Settings\rdp.vssettings”””)

    End Sub

    Sub DualMonitorLayout()

        DTE.ExecuteCommand(“Tools.ImportandExportSettings”, “/import:”“U:\My Documents\Visual Studio 2005\Settings\dual monitor.vssettings”””)

    End Sub

  • Transactions and Unit Testing with NUnit

    Roy Osherove has written a useful library that adds support for wrapping your unit tests inside a transaction (using MSDTC/COM+) which means that you can test your data-layer code and not worry about messing up your database.

    The only problem is I can’t get it working for me:-(

    1. Microsoft increased the security around using COM+ in Windows XP Service Pack 2 and Windows Server 2003 Service Pack 1
    2. The database I’m testing against is on a remote server (running 2003 SP1)

    So even after reading this KB article, I still can’t get it to work. The unit test just hangs, and I think it’s because MSDTC is having problems of some kind.