Visual Studio 11 Beta was made available today (See Jason Zander’s announcement). It can be downloaded from here. These are my first impressions after downloading and trying it.

The New UI
I have already talked about the new Chrome theme. I find it awful, you don’t know what’s enabled and what is not. I wish they change it, and at least give us the possibility to opt for this theme or the classic colored theme.

Startup time
It takes Visual Studio 2010 about a whole minute to start on my machines, so I didn’t have great expectations for Visual Studio 11. However, I am impressed with the startup time, which is about 3 seconds. Excellent.

Opening projects created with a previous version
When I opened a solution build with VS2010 it did not prompt me the classic question about upgrading to the new version. That’s because the project file schemas were not changed between VS2010 and VS11. This is the first time this happens. As for the solution file, it just updated the format version without prompting for anything.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11

Quick launch window
The first thing I do when I install Visual Studio is changing the fonts. But sometimes finding such windows or commands is cumbersome. A new window called Quick launch is now available in the top right corner. You can type for commands and it searches through menus, options, tool windows, etc. displaying a list of results. When you press on a result it executes the command.

Solution Explorer
This is now a hub for functionality previously available in Solution Explorer, Class View, Object Browser, Call Hierarchy, Navigate To, and Find References tool windows.

  

You can search in the solution explorer, view the call graph, hierarchy types etc. As you do this it creates new views kept in a stack. It is possible to navigate between these views with two buttons, Back and Forward that are available in the left side of the Solution Explorer toolbar.

The other buttons are:

  • Home: brings back to the home view of the solution explorer
  • Collapse all: collapses all the items in the Solution explorer three view
  • Sync with Active Document
  • Preview selected items: when this is enabled, as you select files in the tree they are displayed in a special document window, docked on the left of the documents bar. This is excellent because it helps viewing the file (or a method in a file) immediately, yet without opening lots of files (since they are all displayed, one at a time, in the same document window).
  • Properties: opens the properties window for the current item
  • Show all files: as in previous versions
  • View class diagram: shows the class diagram (or creates a new one if one does not exist) for the current item
  • Create a new window containing a copy of the content of this window: this duplicates the solution explorer window, just in case you want multiple views

If you want to quickly find something in the solution explorer, you can use the search control. As you type, the content is filtered to show only the elements that contained the type text. This includes source files, references, images and everything else in the tree.

Search and Replace
There is a new quick window for search and replace. This window is displayed in the top-right corner of the active document window. This window is specific for each document; when you switch to another document, it closes.

It is possible though to open the classic window, which looks like this:

Symbol selection
A nice IntelliSense feature is highlighting in the entire document the symbol under the cursors selection. This helps a lot figuring where else in the code the symbol is used. And also helps when you have variables with the same name in different scopes, because it only highlights the symbols that are visible in the scope of the block where the cursor is.

References Window
The window for adding references has also been redesign. You can see a list of the available components that can be referred. As you hover the mouse over them a check box is displayed on the left, so you can check that component for being added.

NuGet Package Manager
For .NET projects a NuGet package manager is available. You can open it from context menu for the solution or the project.

It opens a dialog where you can search for packages, install, update or remove.

XML Doc comments for VC++
A great feature that was finally added for VC++ is XML doc comments. You can add them to C++ types and methods and generate XML doc files. For generating the output file the /doc switch must be set.

For this sample

///<summary>
///This is a dummy type.
///</summary>
class foo
{
public:
	///<summary>This is a stub method.</summary>
	///<param name="a">This is a dummy parameter.</param>
	///<returns>This method returns a random integer.</returns>
	int bar(int a)
	{
	}
};

The following output file was generated:

<?xml version="1.0"?>
<doc>
  <assembly>"cpp2011demo"</assembly>
    <members>
      <member name="M:foo.bar(System.Int32)">
        <summary>This is a stub method.</summary>
        <param name="a">This is a dummy parameter.</param>
        <returns>This method returns a random integer.</returns>
      </member>
     <member name="T:foo">
       <summary>This is a dummy type.</summary>
     </member>
  </members>
</doc>

The gotcha is that so far it does not work in the automatic way as for C# or VB.NET. When you type /// it does not automatically generate the stubs, you have to add everything manually.

You can use these files to generate MSDN-style documentation using for instance the Sandcastle compiler.

Additional readings

, , , Hits for this post: 3649 .

At the beginning of this year, Microsoft announced a “C++ renaissance”. Quoting from the description of a Channel 9 video with Craig Symonds and Mohsen Agsen:

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

Everybody agrees that Microsoft made C++ a sort of second class citizen in the past years, while the company invested a lot in the .NET framework. Many developers have switched from native development to managed (.NET) simply because it offers a more productive environment. And the postponing of the ISO standard committee in releasing the new C++0x standard only made things worse.

However, with the completion of the new C++ standard this year, Microsoft, apparently, plans to change that, and make C++ again appealing to developers. They already made C++0x features available in the VS2010 C++ compiler and are working on implementing most of the rest for Visual Studio vNext. They are also investing in tools (now labeled Application Lifecycle Management), and for instance are bringing intellisence to C++/CLI. One of the most important areas of development is parallelism, where they are developing the PPL and Agents libraries and now the C++ AMP that they just announced. And also recently the Kinect for Windows SDK beta that provides Kinect capabilities to developers who build applications with C++ (and other laguanges). And in the mean time they hired Erich Gamma in the Visual Studio team.

But this is not enough in my opinion. Improvements in language and tools are an important part, but not everything. It is equally necessary for Microsoft to evangelize it, using any necessary means. Unless they can spread the word, the work might pass unnoticed. To be honest, I was very reluctant about this part, half an year ago, when they announced the “renaissance”. However, looking back at what they done I’d say they are on the right track. Of course, there is still a lot of work to match the “advertising” effort put into .NET. But right now C++ is getting more attention at conferences such as PDC or TechEd, or their publishing assets, such as Channel 9, MSDN or their team blogs. So I tried to assemble a collection of videos, blogs, books and code samples related to C++ or native development that they published since the announcement of the renaissance. So far it looks good, in my opinion.

Channel 9
E2E: Herb Sutter and Erik Meijer – Perspectives on C++
Craig Symonds and Mohsen Agsen: C++ Renaissance
Windows 7 Taskbar Integration for MFC Applications
Tony Goodhew: VC++ Developer Communication – Questions and Answers
Talkin’ C++ with Kate Gregory
MVP Summit 2011: Meet C++ MVPs Angel, PJ, Tom and Sheng
Talkin’ C++ with Alon, Marius, Bruno, and Jim
Talkin’ C++ with Boris Jabes: C++ Intellisense, Game Development, and Boris Faces His Demons
Application Restart and Recovery on Windows 7 in Native Code
Parallel Programming for C++ Developers: Tasks and Continuations, Part 1 of 2
Parallel Programming for C++ Developers: Tasks and Continuations, Part 2 of 2
Conversation with Herb Sutter: Perspectives on Modern C++(0x/11)
First Look: New ALM Tools for VC++ Developers
Modern Native C++ Development for Maximum Productivity
Mohsen Agsen – C++ Today and Tomorrow
Herb Sutter: C++ Questions and Answers
Herb Sutter – Heterogeneous Computing and C++ AMP
Daniel Moth: Blazing-fast code using GPUs and more, with C++ AMP
C9 Lectures: Stephan T Lavavej – Advanced STL, 1 of n
C9 Lectures: Stephan T Lavavej – Advanced STL, 2 of n
C9 Lectures: Stephan T Lavavej – Advanced STL, 3 of n
C9 Lectures: Stephan T Lavavej – Advanced STL, 4 of n
C9 Lectures: Stephan T Lavavej – Advanced STL, 5 of n

Visual C++ Team Blog
Grr… My VC++ Project Is Building Slower in VS2010. What Do I Do Now? (A Step by Step Guide)
C++/CLI IntelliSense in Visual Studio vNext
Exception Boundaries: Working With Multiple Error Handling Mechanisms
Troubleshooting Tips for IntelliSense Slowness
Build Related Improvement in VS2010 SP1
Converting An MFC Ribbon To Designer Format
Enforcing Correct Concurrent Access of Class Data

Parallel Programming in Native Code Blog
Sorting in PPL
How to pick your parallel sort?
The Concurrency Runtime and Visual C++ 2010: Lambda Expressions
The Concurrency Runtime and Visual C++ 2010: Automatic Type Deduction
The Concurrency Runtime and Visual C++ 2010: The decltype Type Specifier
The Concurrency Runtime and Visual C++ 2010: Rvalue References
The Concurrency Runtime and Visual C++ 2010: Transporting Exceptions between Threads
Building Responsive GUI Applications with PPL Tasks

MSDN Magazine
Writing a Debugging Tools for Windows Extension
Writing a Debugging Tools for Windows Extension, Part 2: Output
Writing a Debugging Tools for Windows Extension, Part 3: Clients and Callbacks
Agile C++ Development and Testing with Visual Studio and TFS

Books & Publications
Parallel Programming with Microsoft Visual C++
The Visual C++ Weekly

Code & Samples
Code samples for the Concurrency Runtime and Parallel Pattern Library in Visual Studio 2010
Bing Maps Trip Optimizer
Hilo: Developing C++ Applications for Windows 7
All-in-One Code Framework

, , , Hits for this post: 11401 .

Microsoft has recently announced at the AMD Fusion Developer Summit the introduction of a new technology called C++ Accelerated Massive Parallelism or shortly C++ AMP that helps C++ developers use the GPU for parallel programming. The new technology will be part of Visual C++, integrated with full support (edit, build, debug, profile) in the next version of Visual Studio. It is built in modern C++ on top of DirectX. It will provide an STL-like library, part of the Concurrency namespace, delivered in a amp.h header.

S.Somasegar (Senior Vice President of the Developer Division) said:

By building on the Windows DirectX platform, our implementation of C++ AMP allows you to target hardware from all the major hardware vendors. We expect that it will be part of the next Visual C++ compiler and fully integrated in the next release of Visual Studio experience.

You can read more about it here:

Looking forward for the first CTP and samples.

UPDATE
Herb Sutter introduces C++ AMP at the AMD Fusion Developer Summit 11

Daniel Moth digs deeper into C++ AMP with code samples and more

Herb Sutter

How long is your password? How long it will take a 100,000,000 GPU cores running at what, a million attempts per second to crack your password just by brute force? That where almost a kid can write that. An that is just a tiny example of how game changing this is.

, , , , Hits for this post: 10620 .

I said it before, the Visual Studio installer gets me mad. All is fine until you want to install the Service Pack. After that you cannot install additional components until you uninstall the SP. Because of that, you should make sure you installed the entire Visual Studio package before installing SP1. So I did, but it proved not enough. Here is the story of what happened today.

  1. I installed Visual Studio 2010 Ultimate on my machine (a couple of weeks ago).
  2. I installed Visual Studio 2010 SP1. So far all was good, I was able to use it with no problems.
  3. But then I decided to install the Windows Phone developer tools, following the steps described on this page. After that, when I started Visual Studio 2010 I got this message that SP1 was applied only partially and in order to start the application it must be applied to all components (which was weird because I did that before a couple of times and everything was fine).
  4. I have installed the SP1 again. Then, when I started VS2010 it worked.
  5. However, I wanted to install the Visual Studio Visualization and Modeling SDK to be able to automatically build my text templates when building the solutions, as described here. This SDK needed Visual Studio 2010 SDK installed on the machine. But when I ran the installer for the SDK I got the following error:

    Obviously the error message was non-sense, not only I had VS2010 installed, but it had all the components, and the service pack was applied. Knowing the problems with the service pack, I immediately figured it was the reason.

  6. I have uninstalled the Visual Studio 2010 SP1. Of course, while it was uninstalling it crashed, so I had to start it again.

  7. I started the Visual Studio 2010 installer just to make sure I had all the components installed. However, I ran into this error:

    After several failed attempts I decided to restart Windows. That did the trick and the installer started correctly and I could make sure all the components were there.

  8. I installed Visual Studio 2010 SDK successfully.
  9. I installed Visual Studio Visualization and Modeling SDK successfully.
  10. I installed Visual Studio 2010 SP1 successfully.

Then, three hours later, I could start working with Visual Studio 2010 again. Text templates are automatically built, and the Windows Phone tools are working correctly.

Puff!

, , , Hits for this post: 8780 .

Text templates (aka T4) is a great feature in Visual Studio, that proves helpful in many scenarios. I use it for instance in developing Alchemy. However, it has a significant drawback: it does not generate code automatically when you build your solution. To build the files and generate their output you have to manually run either Run Custom Tool command for each .tt file, or Transform All Templates for the entire solution.

Run Custom Tool

Transform All Templates

The good news is that Visual Studio 2010 has added capabilities for building the text templates files automatically at the build time. Basically, what you have to do is two things: first install the Visual Studio Visualization and Modeling SDK. Second, manually add the following to the project file:

   <PropertyGroup>
      <TransformOnBuild >true</TransformOnBuild>
   </PropertyGroup>

   <Import Project=
     "$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" />

And that should do the trick. When you build the project, the .tt files will also be built.

To read more about this topic see:

, , , , Hits for this post: 10941 .

This Wednesday Google released version 11 of the Chrome Browser. One of the most important addition was the support for speech recognition for English. One can enable speech recognition in an input field by adding the x-webkit-speech proprietary attribute, like in this example:

  <input type="text" x-webkit-speech />

The result should look like this (of course, in Chrome 11, in the other browsers it looks just like a normal input):

You can press the microphone icon and speak. The browser sends the recording to the Google servers, where the speech is transformed into text, which is then displayed in the input field.

While this all is great, it doesn’t work that well, at least not with the English accent of a Romanian. It does work well with simple text such as “hello world”, “chrome 11″, “a beautiful day” or “show me the money”. However, in my tests, most of the time, the recognition failed. For instance “speech input” is sometimes recognized as “speaking book”. “twenty eleven” was most of the time recognized as 27, and very rarely as 2011. For “this is the year twenty-eleven” I got “this is beer 37″, which is probably the number of beers the service had earlier :) . When trying “nothing else matters” I got “smoking a snickers”, “the king of snickers” and “latino snickers” until it finally figured out the correct text. So then I asked the browser “can you handle a longer sentence?” and the answers were “200 number centos”, “can you send unknown person”, “to handle a number sentence”, “200 number sentence”, “can you endorse a number sentence”, “can you handle a medical center”, “can you handle the number symptoms”, “can you pandas syndrome symptoms”, “kings honda center”, etc. etc. No matter what pronunciation I tried, it wasn’t able to pick the right text.

My conclusion is that in theory such a feature is great, but in practice Google still have a lot to work on it.

You can try it out here (with Chrome 11).

You can read more about HTML5 features in this presentation at slides.html5rocks.com.

, , , Hits for this post: 5680 .

Productivity Power Tools is a Visual Studio 2010 add-in, developed by the Microsoft Visual Studio Platform Team and available in Visual Studio Gallery. Of course, you can also download it using Visual Studio Extension Manager, from the Tools menu in Visual Studio 2010.

Its list of features is detailed on the add-in page and I will not enumerate them here. I just want to list the features that I find most useful (at least so far). All these features are enabled by default, but the add-in is very customizable. To enable/disable features or change current settings use the Options dialog and go the Productivity Power Tools page.

Highlight Current Line
The line where your cursor is displayed is highlighted so that you can easily spot it. Here is a screen shot.

Go to Definition
If you press the Ctrl key while the cursor is over a symbol, the symbol appears as a hyperlink and clicking it will take you to the definition.

Move Lines
You can move the current line or an entire selection up with Atl + Up Arrow, or down with Atl + Down Arrow. Useful to avoid Ctrl + X and Ctrl + V, unless you have to move too many lines up or down.

Modified Document Mark
Modified, but yet not saved documents, are indicated with a red dot on the tab.

Pinned Tabs
You can pin tabs on the tab bar. When you hover the cursor over a tab, a pin indicator appears. You can click it and then the tab is pinned on the tab bar, from left to right, so that no mater how many documents you open, the pinned tabs remain visible and you are able to quickly access them.

Undo Close
Recently closed documents are listed in a new tool window called Undo Close. You can double click them and they will be re-opened (and removed from the undo close list).

Floating Tabs
Many developers use two monitors (or even more). Now it is possible to dock floating tabs on a second monitor just as you’d do with a tool window. The following screen shot shows two tabs docked into a separate window on a second monitor.

Solution Navigator
A brand new solution explorer has been created allowing you to easily navigate the solution. You can search it, filter it to see only opened, unsaved, edited or all files, view related information about classes and members, preview images, etc.

The following image shows: the entire solution (left), only the items that contain the word thumb (middle) and only the opened items shown within their projects (right).

Another cool feature is the image preview. All you have to do is hover the cursor over an image and you get a preview of it, as shown below.

Looking forward to seeing these features by default in Visual Studio and not available through an add-in.

, , Hits for this post: 9471 .

I’m using Red Gate’s .NET Reflector for decompiling .NET assemblies. It’s a great tool but it lacks, at least in the free version I’m using, information about the platform architecture of an assembly. Sometimes I want to know whether an assembly was built for Any CPU, x86 or x64.

The tool that help you find this information is CorFlags.exe from Windows SDK. It displays or configures the corflags section of a PE image. Here is an example of the output of corflags.exe:

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 1
ILONLY    : 1
32BIT     : 0
Signed    : 0

The platform architecture is encoded in a combination of the PE and 32BIT flags:

  • Any CPU: PE=PE32 and 32BIT=0
  • x86: PE=PE32 and 32BIT=1
  • 64-bit: PE=PE32+ and 32BIT=0

So for the example above, PE is PE32 and 32BIT is 0, thus the platform architecture is Any CPU.

You can read more about this tool on Gaurav Seth’s blog.

, , , Hits for this post: 8735 .

When you run your (unmanaged/C++) application in debugger, you see at the end a report of memory leaks (if any are detected). Something like this:

Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {381} normal block at 0x001FFC30, 54 bytes long.
Data: < x > 0C 00 B9 78 12 00 00 00 12 00 00 00 01 00 00 00
d:\marius\vc++\memoryleakstest\memoryleakstestdlg.cpp(163) : {380} normal block at 0x001FFBF0, 4 bytes long.
Data: <@ > 40 FC 1F 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp(306) : {374} client block at 0x001FFA38, subtype c0, 68 bytes long.
a CWinThread object at $001FFA38, 68 bytes long
Object dump complete.

Some of them can be fixed immediately, because when you double click on them Visual Studio will take you to the line where the allocation was made. Some of them are harder to spot, because Visual Studio is not able to do the same. Question is how do you find the source of those allocations? Luckily, there is this global variable called _crtBreakAlloc, that can be used to force the debugger to stop the execution when a certain block is allocated.

In order to use that, you should follow several steps:

  • First, you have to find a reproducible sequence that produces the same memory allocation number. When memory blocks are allocated, they are identified with a number, called allocation number. This number is reported by Visual Studio in brackets when it lists the memory leaks (e.g. {381}).
  • Second, you have to put a breakpoint somewhere in your program to force a stop at the beginning of the execution. That means you could use function main(), your CWinApp derived class constructor, function InitInstance() or other, depending on your application type and how early in the execution of the program the block that leaks is allocated. The smaller the allocation number is, the earlier in the execution the allocation occurs.
  • Run your program in debugger.
  • When the program stops (at the first breakpoint) open the Watch window and add the following expression: {,,msvcr90d.dll}_crtBreakAlloc in the Name column. In the Value column (which by default should have the value -1) write the allocation number. Take notice that msvcr90d.dll (which is the DLL that contains the C++ runtime library) is specific to Visual Studio 2008 (and is the debug version). If you use another version of Visual Studio, you have to use the appropriate DLL.
  • Continue debugging.
  • When the block identified by the allocation number set in the Watch window is allocated, the debugger will stop the execution and jump to a line from dbgheap.c.

    In order to see the line in your code that triggered the allocation, open the Call Stack window and find, from top down, the first function from your own code.

    That will lead you to the source of the memory leak.

To read more about this topic see:
How to: Set Breakpoints on a Memory Allocation Number
How to use _crtBreakAlloc to debug a memory allocation

, Hits for this post: 12377 .

A week ago I was reporting about the problems I had experienced with Office 2010. That was not the end of the story, and it’s probably fair enough to tell how it ends.

After installing Office 2010 64 bit and then 32 bit and both crashing every other 5 minutes, I returned to Office 2007. But then I got the help of Microsoft Support who provided a couple of scripts to clean-up the Windows Registry of anything related to Office 2007 and Office 2010. (The script for Office 2007 is available here; the one for Office 2010 is not yet published). I have then installed Office 2010 32 bit on a clean Registry and now all applications in the package work like a charm. No hanging, no crashing whatsoever. And I must say I was impressed by the support people, how they helped, how they called to check if everything was working, etc. The kind of support I wish to see everywhere.

I also learned that installing the 64 bit version is not recommended unless you really have some demands, like working with huge files, over 2GB (though I’m not sure what are the scenarios when one has Excel files bigger than 2GB). Add-ins for Office 32 bit might not work with the 64 bit version. (Though the add-ins I had in 2007 worked without any update when I installed Office 2010 32 bit.) More information about the 64 bit of Office 2010 can be found in this TechNet article.

, Hits for this post: 6696 .