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: 3006 .

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: 5022 .

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: 3273 .

Microsoft has made available a first beta version of an experimental version of .NET 4.0, called .NET Framework 4.0 Beta 1 Enabled for Software Transactional Memory v1.0. Since that is quite a long name, the short one is STM.NET. This is a special version of .NET 4.0 that enables software transactional memory for C#. It allows programmers to demarcate regions of code as operating in an atomic, isolated transaction from other code running concurrently. The means to do this is a delegate called Atomic.Do, or try-catch blocks. Might be that in the future an ‘atomic’ block will be added to the language(s).

This first version of the framework, also comes with additional tools:

  • tooling (debugging, ETW tracing)
  • lock interoperability
  • interoperability with traditional transactions
  • annotations (how methods run in transactions, suppressed transactions on methods, etc.)
  • static and dynamic checking of annotations

On the other hand there are some limitations:

  • only works for C# for now
  • cannot be installed on a machine with VS 2010, nor the opposite
  • there is only a 32-bit version

More information about it can be found at the STM team blog or MSDN DevLabs.

, , , Hits for this post: 5074 .

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: 5431 .

In a recent post I wrote about Code Contracts in .NET. Now you can find a more detailed article on this topic at sharparena.com. In this article I’m providing more information and examples on:

  • pre-conditions
  • post-conditions
  • object invariants
  • asserts and assumptions
  • quantifiers

In additions, you should check the official user documentation, which can be found here.

, , , , Hits for this post: 4895 .

Google has unveil the next product they will launch later this year. It’s called Wave and it’s a communication protocol. It’s like the email of the 21st century, but much more than that. Wave is a collaborative product. The waves are communication objects, both conversation and documents, allowing people to almost instantly communicate on the web.

Waves allow people to send emails, but do it in an instant messaging style, sharing media like pictures and movies and being able to see live what the others are typing or sharing, and playback the entire conversation.

Wave is also an open source platform for building blogging sites or discussion groups. It provides APIs for collaboratively editing documents, building games (and playing back the moves), integrating with other communication systems (like twitter) and others.

To see what wave actually is, see this preview.

You can learn more about the waves here and here.

, Hits for this post: 3203 .

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: 8324 .

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: 6255 .

Microsoft has announced the availability of Visual Studio 2010 & .NET 4.0 beta 1 for MSDN subscribers starting this Monday, and for the public starting this Wednesday.

According to Kirill Osenkon, 95% of the planned functionality is already there. This new version of Visual Studio is WPF based. Among the many new features, one important addition is the inclusion of F# as a first class language targeting the .NET framework. More information on the new features are available on Jason Zander’s blog.

The bits can be downloaded from here.

, , Hits for this post: 3929 .