Archive for April, 2010


Okay, so there is a SQLCMD Mode for the query window in Management Studio for SQL Server. However, what I didn’t know was that there is also a SQLCMD Mode for the Transact-SQL Editor in Visual Studio 2010. Apparently, in order to compile any SQLCMD syntax inside of a script, such as the post deployment script for a database project, you must have SQLCMD turned on to avoid any parser errors. Cheers!

When I was migrating our TFS build to .NET Framework 4.0 from 3.5 SP1, I got the following error.

error MSB4062: The “xxx” task could not be loaded from the assembly xxx.dll. Could not load file or assembly ‘file:///xxx.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Confirm that the declaration is correct, and that the assembly and all its dependencies are available.

To resolve this error, you’d have to change the full path to the directory of MSBuild.exe in the TFS build service configuration file.

  1. Stop the Visual Studio Team Foundation Build service.
  2. Open the file C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config.
  3. Set the path for the new .NET Framework in the MSBuildPath setting: <add key="MSBuildPath" value="C:\Windows\Microsoft.NET\Framework\v4.0.30319" />
  4. Start the service.

Today I migrated our Visual Studio 2008 solution to Visual Studio 2010, and I started getting the following error when I kicked off a TFS build.

“The working folder [/source] is already in use by the workspace [workspace name];[owner] on computer [tfs server].”

After some research, it turned out that I just needed to run a command to clear the workspace cache.

tf workspace /delete /server:[tfs server] [workspace name];[owner]

Not too bad. 🙂

Cool F# StarCraft Bot

I stumbled across this nifty StarCraft Bot written in F# from Chris Smith’s blog and thought I’d share it.

Writing a StarCraft Bot in F#

Time to make some bots….

Very often, I want to disable the X button on a windows form so I can control what happens when a user closes the form. The following code has been working great for dialogs.

        public static extern int ExitWindowsEx(int uFlags, int dwReason);

        [DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
        private static extern IntPtr GetSystemMenu(IntPtr hwnd, int revert);

        [DllImport("user32.dll", EntryPoint = "GetMenuItemCount")]
        private static extern int GetMenuItemCount(IntPtr hmenu);

        [DllImport("user32.dll", EntryPoint = "RemoveMenu")]
        private static extern int RemoveMenu(IntPtr hmenu, int npos, int wflags);

        [DllImport("user32.dll", EntryPoint = "DrawMenuBar")]
        private static extern int DrawMenuBar(IntPtr hwnd);

        private const int MF_BYPOSITION = 0x0400;
        private const int MF_DISABLED = 0x0002;

        public MainForm()

            IntPtr hmenu = GetSystemMenu(this.Handle, 0);
            int cnt = GetMenuItemCount(hmenu);

            // remove 'close' action
            RemoveMenu(hmenu, cnt-1, MF_DISABLED | MF_BYPOSITION);

            // remove extra menu line
            RemoveMenu(hmenu, cnt - 2, MF_DISABLED | MF_BYPOSITION);


However, the above code doesn’t work when the form is the main window of the program. So, I find the following method more robust.

        protected override CreateParams CreateParams
                CreateParams cp = base.CreateParams;
                const int CS_NOCLOSE = 0x200;
                cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
                return cp;