I have updated my Visual Studio addin that displays the status of a build/clean/deploy action. If you get the latest version, 1.2, and are running Visual Studio 2005, 2008 or 2010 (they are all supported) on Windows 7, the progress of the build is also displayed on the Taskbar, on the item corresponding to the Visual Studio instance.

The following images show no progress, different progress steps, and an error during the build/clean/deploy, both for Visual Studio 2008 and Visual Studio 2010 (Beta 2).

No progress

Build progress

Build progress

Error during build

Build progress

Error during build

This was possible by using the Windows 7 Taskbar interop library available on MSDN Code Gallery here.

You can get the latest version of the addin from the Visual Studio Gallery at this link.

, , , , , Hits for this post: 3103 .

I ran across a breaking error while trying to install SQL Server 2008 on a Windows 7 machine. The rule “Previous releases of Microsoft Visual Studio 2008″ failed. Here is the error message that I received.

Rule Previous releases of Microsoft Visual Studio 2008 failed.

Rule "Previous releases of Microsoft Visual Studio 2008" failed.

That was odd, because I actually had Visual Studio 2008 with SP1 installed on that machine. So I start looking for answers and found this Knowledge Base article (KB956139) from Microsoft that said that if Visual Studio 2008 SP1 was installed then “No action is required.” Obviously that didn’t help at all.

Then I start looking into the logs (which are located under C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\). There is a log file called Detail.txt that revealed the following error:

2009-11-25 17:09:35 Slp: Sco: Attempting to create base registry key HKEY_LOCAL_MACHINE, machine
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey SOFTWARE\Microsoft\DevDiv\VS\Servicing\9.0\IDE
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey 1033
2009-11-25 17:09:35 Slp: Sco: Attempting to get registry value SP
2009-11-25 17:09:35 Slp: Sco: Attempting to get registry value kind for value SP
2009-11-25 17:09:35 Slp: Found Microsoft Visual Studio 2008 edition IDE, language 1033, SP level 0.
2009-11-25 17:09:35 Slp: Microsoft Visual Studio 2008 edition IDE, language 1033 does not have required SP level. Upgrade Microsoft Visual Studio 2008 to the SP1 before installing SQL Server 2008.
2009-11-25 17:09:35 Slp: Sco: Attempting to create base registry key HKEY_LOCAL_MACHINE, machine
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey SOFTWARE\Microsoft\DevDiv\VS\Servicing\9.0\STD
2009-11-25 17:09:35 Slp: Sco: Attempting to create base registry key HKEY_LOCAL_MACHINE, machine
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey SOFTWARE\Microsoft\DevDiv\VS\Servicing\9.0\PRO
2009-11-25 17:09:35 Slp: Sco: Attempting to create base registry key HKEY_LOCAL_MACHINE, machine
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey SOFTWARE\Microsoft\DevDiv\VS\Servicing\9.0\VSTD
2009-11-25 17:09:35 Slp: Sco: Attempting to open registry subkey 1033
2009-11-25 17:09:35 Slp: Sco: Attempting to get registry value SP
2009-11-25 17:09:35 Slp: Sco: Attempting to get registry value kind for value SP
2009-11-25 17:09:35 Slp: Found Microsoft Visual Studio 2008 edition VSTD, language 1033, SP level 1.
[...]
2009-11-25 17:09:35 Slp: Rule evaluation done : Failed

It looked like the IDE’s version was not correctly specified in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\9.0\IDE. This post from Heath Stewart’s blog explains how to detect the version of Visual Studio 2008. The SQL Server 2008 installer looks in the right place, so the only explanation was that there was incorrect data there. So I started regedit.exe and looked at the key. To my surprise there was no IDE key there.

No key for IDE

No key for IDE

But then I remember I was running Windows 7 64-bit and there are several registry editors (I’m still confused which to use when). So I opened the one located under C:\Windows\SysWOW64\ and this one shown more keys under DevDiv, and under Servicing\9.0 I could also see IDE.

Incorrect version of VS 2008 IDE

Incorrect version of VS 2008 IDE

As you can see from the screenshot, the SP value was 0, and SPName was “RTM”. The Visual Studio 2008 SP1 installer didn’t update these keys. (Well, that wasn’t such a big surprise, because the Visual Studio 2008 SP1 installer really sucks, but that’s another story.) So, what I did was to change those keys as shown in the following image. SP and SPIndex should have the value 1, and SPName should be “SP1″.

These are the correct values

These are the correct values

Also, make sure that the same values under the parent (Servicing\9.0) are 1.

Correct values for SP and SPIndex unde Servicing\\9.0

Correct values for SP and SPIndex unde Servicing\9.0

After making these changes I ran the setup again, and this time it worked like a charm. If you run into the same error and Visual Studio 2008 SP1 is installed then check these registry values and make sure they indicate that SP1 is installed.

, , , , Hits for this post: 2349 .

I was doing some development in Visual Studio 2010 Beta 2 and I had to add some references to my projects. When I opened the Add Reference dialog I realized something was wrong: it was working very fast. Since I’m using Visual Studio 2008 for every day development I am used to wait tens of seconds before the dialog loads all the references and only after that I can select what I want. But in Visual Studio 2010 it popped up instantly and all the tabs were browse able at the same speed. This was not normal. Usually new versions are slower that older ones (and I suspect Visual Studio 2010 has such features), but Add Reference dialog works great.

Then I browsed the web I came across this post from Scott Guthrie who explain what has changed:

  • default active tab when the Add Reference dialog is opened is now Projects, and not .NET
  • .NET and COM tabs load asynchronously in worker threads, populating the lists as references are discovered, without blocking the UI thread, which means you can browse through the references as soon as you open the tab

There are only two things that I can say: first is that I’m impressed. I now get instantly what it used to take maybe half a minute. Second is that I’m puzzled that it took so many years to implement that. Anyway, good work.

, , Hits for this post: 3007 .

With VC++ Feature Pack Microsoft has added new classes to MFC to provide support for new controls. However, these controls were not available from the designer. One had to manually wrote all the code for enabling an application to use these controls. Visual Studio 2010 Beta 2, released a couple of weeks ago, provides support in the designer for these controls.

MFC controls in the Toolbar

MFC controls in the Toolbar

Here is a screen shot of a dialog application with these controls:

New MFC Controls

New MFC Controls

The controls are:

  • Color button (CMFCColorButton): represent a color picker control allowing users to select a color
  • Font combo box (CMFCFontComboBox) : represent a combo control that displays a list of fonts available in the system
  • Edit browse (CMFCEditBrowseCtrl): an editable control with a button that displays a dialog for selecting a file or a folder
  • Visual Studio list box (CVSListBox): an editable list control with buttons for adding, removing or rearranging items in the list
  • Masked edit (CMFCMaskedEdit): a masked edit control that has a string template representing the structure of the allowed input, which is validated against the value provided by the user
  • Menu button (CMFCMenuButton): displays a pop-up menu (from a menu resource) and reports the command selected by the user
  • Property grid (CMFCPropertyGridCtrl): an editable property grid control
  • Shell list (CMFCShellListCtrl): a list control that displays the files and folders from you system just list Windows Explorer list view does
  • Shell tree (CMFCShellTreeCtrl): a tree control that displays the folder from your system just like the Windows Explorer folder view does
  • Link control (CMFCLinkCtrl): is a special button that has the appearance of a hyperlink and invokes the target link when pressed

Not all the properties for these controls are available from the designer. For instance the properties list still needs hand coding, it is not possible to select a menu resource for the menu button nor the starting point for the shell tree and list. However, having them available in the toolbar is a good step forward.

, , , , Hits for this post: 5023 .

If you are still using Visual Studio 2005 and need to develop WCF services you need the following:

The problem with the later is that Microsoft no longer supports it. Visual Studio 2008 is supposed to be used for developing such projects. The license for the CTP has expired on June 30th 2008. You can read more about that here. What that means is that you can no longer develop WCF applications in Visual Studio 2005 and should upgrade to Visual Studio 2008. However, as an exercise, I wanted to see if I could still install the WCF extensions in Visual Studio 2005 and have it work side by side with Visual Studio 2008.

First, I had to find the old CTP with the Visual Studio 2005 extensions. It can be downloaded from here. However, when I run it, I got the following error:

WCF Extensions for Visual Studio 2005 Setup Error

WCF Extensions for Visual Studio 2005 Setup Error

The curious thing was that .NET 3.0 was already installed on my machine. I soon realized I was having .NET 3.0 SP2, and the installer was looking for .NET 3.0. Of course, you cannot install 3.0 when a newer version (such as 3.0 SP2) is already installed. So the only option was to change the installer.

Orca is a database editor, allowing you to create and edit MSI files and merge modules. It is provided as a part of Windows Installer SDK. But you can also find stand alone downloads, such as this.

After installing Orca, you can open the MSI file. From Tools > Validate… one can run a validation on the installer. It shown the following errors:

ICE08 ERROR Component: WCFSvcConfigEditor_dll has a duplicate GUID: {714D044E-3136-457E-ADD7-AE3D0FEF021A}
ICE16 ERROR ProductName: ‘Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP’ is greater than 63 characters in length. Current length: 83
ICE77 ERROR CA_CommitHelpTransactionNoRB.3643236F_FC70_11D3_A536_0090278A1BB8 is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table

I had to do the following fixes:

  • replace the first occurrence of this GUID {714D044E-3136-457E-ADD7-AE3D0FEF021A} with another one
  • trim the name “Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP” to “Visual Studio 2005 extensions for .NET Framework 3.0 SP2″
  • change the Sequence number of the CA_CommitHelpTransactionNoRB.3643236F_FC70_11D3_A536_0090278A1BB8 action in he InstallExecuteSequence table from 6601 to 6599 so that it is in between InstallInitialize (1500) and InstallFinalize (6600)

But then, came the biggest problem: making the installer work with .NET 3.5 SP2. It was looking in registry for the following key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{15095BF3-A3D7-4DDF-B193-3A496881E003}. The GUID {15095BF3-A3D7-4DDF-B193-3A496881E003} corresponds to .NET 3.0. So in order to make it work with .NET 3.0 SP2 one needs to replace the GUID with {A3051CD0-2F64-3813-A88D-B8DCCDE8F8C7} for the SearchForWinFXruntimeX86Install signature in the RegLocator table.

Once those changes are made all you have to do is save. However, the “Copy embedded steams during ‘Save As’” option should be checked from Tools > Options > Database, before doing the saving. Otherwise the embedded CAB is not copied and the installation won’t work.

Running the modified installer works successfully.

Setup start page

Setup start page

Setup finished

Setup finished

If you start Visual Studio 2005 you can create a new project from one of the WCF project templates.

WCF Project Templates

WCF Project Templates

You can download the altered MSI file from here: [download id="5"].

Note: I must say this again: this scenario is no longer supported. The license for this CTP for WCF extensions for Visual Studio 2005 has expired in 2008. You should upgrade to Visual Studio 2008 to develop WCF applications.

, , , , Hits for this post: 3274 .

MSDN Code Gallery made available an update for the Windows API Code Pack for .NET Framework 3.5 (or above), a library that provides access to some Window 7 features and some existing features in previous operating systems. It includes:

  • Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.
  • Known Folders, Windows 7 Libraries, non-file system containers, and a hierarchy of Shell Namespace entities.
  • Windows 7 Explorer Browser Control.
  • Shell property system.
  • Windows Vista and Windows 7 Common File Dialogs, including custom controls.
  • Windows Vista and Windows 7 Task Dialogs.
  • Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)
  • Sensor Platform APIs
  • Extended Linguistic Services APIs
  • Power Management APIs
  • Application Restart and Recovery APIs
  • Network List Manager APIs
  • ommand Link control and System defined Shell icons.

The requirements for using this library are:

  • .NET Framework 3.5
  • Windows 7 RC (some features work on previous operating systems too)
  • DirectX features have dependency on Windows SDK for Windows 7 RC and March 2009 release of DirectX SDK

You can download the Code Pack library from here.

, , , Hits for this post: 5432 .

Visual Studio 2010, currently in beta 1, replaces VCBuild with MSBuild as the build system, aligning C++ with the other languages that already used MSBuild. The VC++ team has already posted several articles on it’s blog about the new build system. Channel 9 has published recently a video with Bogdan Mihalcea, a developer in the VC++ build and system project team, talking about MSBuild. You can watch the video here.

, , , Hits for this post: 4235 .

Visual Studio 2010 has support for code contracts that allow to express pre-, post-conditions and invariants to your .NET code.

Let’ say you want to create a function to return a random value in a range. This could look like it:

    class Program
    {
        Random rng = new Random();

        public int GetRandom(int min, int max)
        {
            return rng.Next(min, max);
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            int n1 = p.GetRandom(10, 20);
            int n2 = p.GetRandom(10, 10);
        }
    }

However, at a rough analysis one can find two problems:

  • Second call to GetRandom(), is not well formed, because the range is 0
  • Radnom.Next returns a value greater or equal to the first argument, and lower than the second.

What code contracts provide is a mean to check that some statements, like:

  • maximum value of the range should always be greater than the minimum value
  • returned value should always be in the interval, equal or greater than the minimum, and equal or less than then maximum

The first is a pre-requisite, and the second is a post-requisite. We can specify those with:

        public int GetRandom(int min, int max)
        {
            Contract.Requires(max > min);
            Contract.Ensures(Contract.Result() >= min &&
                             Contract.Result() <= max);

            return rng.Next(min, max);
        }

The Contract class is available in namespace System.Diagnostics.Contracts. To enable the static checking, you have to go to Project Properties > Code Contracts and select "Perform Static Contract Checking."

Code Contracts Property Page

Code Contracts Property Page

When you build, you get the following warnings:

Code Contracts warnings

Code Contracts warnings

The first says that the call GetRandom(10, 10) does not match the pre-condition. The second warning indicates that the post-condition is not met. It isn't possible to know whether Random.Next() returns a value that hods the post-condition. But if you check the "Perform Runtime Contract Checking" it asserts at runtime, when the return value is outside the interval (not possible with this code sample).

You can read more about code contracts on the BCL team's blog. It features a list of possible constructs for pre- and post-requisites, but also object invariants.

Code Contracts are also available for Visual Studio 2008. For downloads and additional information check the following links:

, , , , Hits for this post: 8325 .

Here is a list of new things in Visual Studio 2010 for unmanaged development.

Visual Studio IDE:

Visual C++

Visual Studio Tools:

Additional readings:

, , , , Hits for this post: 6256 .

Yesterday I have installed Visual Studio 2010 and decided to try my VSBuildStatusAddin. It work on the first try, only with a change to the .AddIn configuration file.

Here is some screen shots in Visual Studio 2010.

VSStatusBuild in Visual Studio 2010

VSStatusBuild in Visual Studio 2010

Visual Studio 2010 about window with VSbuildStatus addin

Visual Studio 2010 about window with VSbuildStatus addin

The images above show a new version of the add-in, 1.1.0. This new version provides the following features:

  • displays the build/clean/deploy progress on a status bar
  • shows information about latest available version with link to download page
  • as already explained, works in Visual Studio 2010

The new version is available at the Visual Studio Gallery.

, , , , Hits for this post: 5022 .