NuGet has recently added support for native projects. This simplifies a lot deployment of native libraries. Even though cpplinq is not a big library (in fact is just a header file) I have created a NuGet package so that you are able to automatically add it to your project.

Here is what you have to do.

  1. Make sure you have NuGet 2.5 or newer, otherwise the NuGet package manager won’t show up in your VC++ projects.
  2. In the context menu for your project choose Manage NuGet Packages…
    cpplinqdemo1
  3. Search for cpplinq and install the package.
    cpplinqdemo2
  4. Include the cpplinq.hpp header and start using the library. Here is a sample to test that everything is all right.

Notice that all the settings for library (such as adding the proper entry for the include directories or defining NOMINMAX so that min and max macros will not be defined for the project) are automatically performed, so you can focus on coding.

, , , , , , , Hits for this post: 43144 .

Let’s say you have this VC++ project (or maybe more) targeting a 64-bit platform (x64 or IA64). You have the sources, everything is set. You build the solution and your project is skipped. You try again, maybe do a rebuild. The project is still skipped. You check the solution’s configuration manager, and the project is indeed checked for building. What could be wrong?

You open the project properties but the page doesn’t load. You get this error:

What’s happening?

What’s happening is that you are missing the x64/IA64 compiler and tools. You did not check them when you installed Visual Studio.



You have to go back to the setup and add this component. However, you must notice that if you have installed the service pack for Visual Studio (regardless the version and edition) you must remove the service pack first, run the original setup, add the x64/IA64 compiler and tools and then install the service pack back. Otherwise the original setup for Visual Studio will fail. The reason is the service pack installation overrides things, making the original setup unable to run again.

, , , , , Hits for this post: 48788 .

Visual Studio 11 brings many new things for native development, including support for new features from C++11 (unfortunately not all), or ability to write Metro apps with C++/CX including modeling the UI with XAML. In this post I will talk a bit about three favorite features that I noticed immediately after trying VS11 from Windows 8 Developer Preview.

Use of namespaces
Finally, I see namespaces promoted in native code. Yes, it’s C++/CX and they were probably forced to use namespaces for a consistent experience from the various languages that target the Windows Runtime, but it’s a very nice change to the default templates for C++ projects where everything is put in the global namespace. I can only hope they will improve that in this version or the next for standard C++ applications (whether Win32 console apps or MFC apps).

UPDATE: looks like I wasn’t clear enough, I’m not saying namespaces is a new C++ feature (duh), I’m saying Visual Studio templates for C++ don’t promote that. Create a Win32 project, an MFC project, and ATL project, there are no namespaces. You’d have to code everything manually, but if you do it, you mess the wizards. So, what I’m saying is that I hope we can see namespaces promoted for other project and item templates too.

Partial classes
I already wrote about partial classes, but I want to reiterate this feature. Partial classes gives you the ability to define a class in several files. This is great because developers and code generator tools such as designers can edit different parts of the same class without interfering one with the other. This feature made it possible for supporting XAML user interfaces in C++/CX Metro applications.

I’m actually wondering why isn’t this already part of standard C++ and I can only wish that the next version (which hopefully will not take another decade to conclude) will include this feature.

Better Syntax Highlighting
Below is a comparison for the same piece of code highlighted by Visual Studio 2010 on the left, and Visual Studio.vNext (11) on the right.

There is hardly any formatting in VS10. However, on the other hand, the highlighting in VS11 is beautiful. User defined types (including library types) are displayed with another color than the built-in types (such as int), including in their definition. STL types (string, vector, etc.) are finally identified as types and displayed with the appropriate color. Also the name of parameters is displayed in italics which makes them easily identifiable. There are other things about the highlighting, but these striking changes.

, , , , , , Hits for this post: 47708 .

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

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:

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

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

For those that attended my last evening presentation about F# at Ronua Roadshow in Timisoara (but not only), here is the demo I’ve shown, and one that I planned to show but didn’t due to lack of time. The purpose of these demos was to shown simple Windows Forms applications written in F#.

Mandelbrot Fractal
A Mandelbrot set is a set of points in the complex plane, whose boundary forms a fractal. The fractal, known as Mandelbrot fractal, is obtain by associating a color with each point in the complex plane (or rather a subset of it). The color is chosen based on the result of computing the value of the complex quadratic polynomial Z(n+1) = Z(n)^2 + c for a number of iterations (100, 200, etc.). You can read more about it on Wikipedia.

The program that I shown exhibits traits of both functional (for computing the fractal) and object oriented (for displaying the fractal) paradigms. It is a variation of the program available here, for which I kept the functional part (computing the Mandelbrot set is not very fast, I must warn you), but redone the user interface part. You can use the mouse to drag the fractal and the wheel to zoom in and out.

You can download it from here.

Game of Life
I blogged about this two years ago, when F# was still far from a final release. In the meantime, syntax has changed, classes have changed, so if you try to run that implementation of mine you’ll run into some errors. I have updated the code to run correctly with Visual Studio 2010.

You can download it from here.

, , , Hits for this post: 39149 .

A new version (1.3) of VSBuildStatus add-in for Visual Studio 2005, 2008 and 2010 is available. It allows you to configure the add-in window to automatically show up when a build/clean/deploy process starts, and/or automatically close when the operation ends.

  • To enable the automatic show of the add-in window when a build/clean/deploy operation starts, check Pop-out automatically when starting a build
  • To enable the automatic hiding of the add-in window when the build/clean/deploy operation ends, check Auto hide when the build ends
    • you can set a delay interval for the hiding, varing from 0 to 300 seconds; if the delay is 0, the window is hidden immediatelly after the build ends
    • to keep the window shown when error(s) occurred during the build/clean/deploy operation, check DO NOT auto hide when an error occurs

Here is a screen short of the properties window. It opens from the Settings button.

The add-in is available on the Visual Studio Gallery.

, , , , Hits for this post: 49381 .

Today Microsoft release officially Visual Studio 2010 and .NET Framework 4.0, with five major release events and many others across the globe. You can download it from MSDN. Those that don’t have an MSDN subscription can try the evaluation versions available here. Express editions are still available for free and can be downloaded from here.

During past months I have wrote various posts about the changes and new features for Visual C++. A summary of these articles are available here.

An important change in Visual Studio 2010 is that F#, now at version 2.0, is bundled in the IDE, just as the other languages, C++, C# and VB.NET. After 7 years in development it had become a first class language with today’s release.

More information about the release can be found here:
http://blogs.msdn.com/somasegar/archive/2010/04/11/announcing-visual-studio-2010-and-net-framework-4.aspx
http://blogs.msdn.com/dsyme/archive/2010/04/12/f-2-0-released-as-part-of-visual-studio-2010.aspx
http://blogs.msdn.com/jasonz/archive/2010/04/12/ship-it-visual-studio-2010-net-framework-4-now-available.aspx

Hits for this post: 28613 .

I this post I will talk about the deployment changes in VC++ 2010. When you deploy an application to another machine you have to install not only the application but all the libraries that it depends on. When you build with VC++, you have dependencies on CRT (C/C++ runtime) and possible on MFC and/or ATL.

Visual Studio 2005 introduced a new deployment model for Windows client applications based on isolated applications and side-by-side assemblies. Assemblies can be either shared (globally registered in the system, installed in the Global Assembly Cache – GAC folder in Windows – and available to all applications) or side-by-side (described with a manifest, distributed with the application and available only to that application).

In Visual C++ 2005, library assemblies (such as MFC, ATL, CRT) have been rebuilt as shared side-by-side assemblies and installed in the native assembly cache, WinSxS folder in Windows. That means they are not globally registered in the system, but are globally available to the applications that specify a dependency with a manifest file.

With VC++ 2005 or 2008 there are several options for deployment:

  • static linking: when you link your application statically against VC++ libraries (CRT, MFC or ATL) the application doesn’t have any dependencies so you don’t have to deploy any other VC++ DLLs to the target machine
  • shared side-by-side assemblies: the VC++ DLLs are deployed in the WinSxS folder; this can be done either with the Visual C++ Redistributable Merge Modules or the Visual C++ Redistributable Package; the application requires a manifest file that describes the dependent DLLs and their version
  • private assemblies: the VC++ DLLs are all installed in the same folder with the application; the application requires a manifest file

When you deploy an application built with Visual Studio 2005 or 2008 a manifest file that describes the dependencies, whether you deployed these VC++ DLLs in the local folder or they where installed in the WinSxS folder. If the manifest is missing you get an error. The next image shows the error received when running an MFC application (called Wordpad2008) build with VC++ 2008 on another machine without a manifest.

Though the purpose of this change was to simplify deployment, the result was probably the opposite. As a result Microsoft changed deployment requirements in Visual C++ 2010. You can now deploy applications without a Fusion or satellite manifest. All you need to do is copy the VC++ dependent DLLs to the application folder and run. The next image shows an MFC application (called Wordpad2010) built with VC++ 2010 running on another machine, without a satellite assembly. No error occurs any more when trying to start the application, because local deployment no longer require a satellite manifest.

With VC++ 2010 there are several options for deployment:

  • static linking: same as earlier
  • central deployment: the VC++ DLLs are deployed in the system32 folder; this is useful for updates, because Windows automatically identifies and updates the DLLs that are deployed here
  • local deployment: the application executable and its dependent DLLs are all installed in the same folder; no manifest file is required.

To find more information about deployment and manifest files I suggest these links:

, , Hits for this post: 51064 .