Several CTPs for Visual Studio 2014 have been released so far. The 3rd and 4th CTPs can be actually used with a Windows Azure Virtual Machine. If you have a Windows Azure account you can go ahead and create a VM. If you are an MSDN Subscriber or you have a trial account, you have a number of free hours that you can use, so you won’t have to pay anything to run VS2014 CTP in the clound.

NOTE: Details about the limits and cost in Windows Azure are available here (also see this article).

Below is a step-by-step walk through of how to create and start a VM for Visual Studio 14 CTP 4.

Step 1: Log to Windows Azure.

Step 2: Create a new virtual machine.

In the Azure portal press the New button.
azure_vs2014ctp_1

Select Compute > Virtual Machine > From Gallery
azure_vs2014ctp_2

Choose the Visual Studio 2014 CTP 4 Image
azure_vs2014ctp_3

Select the virtual machine configuration
azure_vs2014ctp_4

azure_vs2014ctp_5

azure_vs2014ctp_6

Step 3: Wait until the virtual machine starts up.

This may take a few minutes.
azure_vs2014ctp_7

azure_vs2014ctp_8

Step 4: Connect remotely to the virtual machine.

See How to Log on to a Virtual Machine Running Windows Server.

Note: You have to authenticate with the username (make sure you use the format machinename\username) and the password you have created, not the account you are initially prompted in the RDP window.

azure_vs2014ctp_9

Step 5: Launch and use Visual Studio 2014 CTP.

azure_vs2014ctp_10

, , , , Hits for this post: 19229 .

Microsoft has announced that Visual Studio 2012 Update 2 will bring support in Visual Studio and TFS for git. They already used git on codeplex and this move shows how popular git has become. I don’t work much with git, but as I said codeplex uses git, and I used it for working on cpplinq. However, the experience with Git Source Control Provider extension for Visual Studio was not the most pleasant. Fortunately, Visual Studio Tools for Git is a different story, allowing you to work exclusively from Visual Studio, without the need of addition tools. After giving it a try, I must say that even if it’s in CTP and still has some issues, it’s a totally different story than the previous extension or external tools I used. However, support for git will not be added to the previous versions of Visual Studio.

Here is more about the support for git:

Before you can start working with git, you need two things:

  1. Visual Studio 2012 Update 2 CTP 2
  2. Visual Studio Tools for Git

Extensions manager

In this post I’ll show what it takes to clone a git repository, work on the project, commit and push the changes on the remote branch.

To clone a repository you have go to Connect to Team Projects in Team Explorer, and under Local Git Repositories use the Clone pane to enter the URL of the server repository and the local destination. After the repository has been cloned, it shows up in the list, as shown below.

Cone a git

You can change the settings, such as your credentials from the Settings pane.

Git settings

To view your changes you can use the Git Changes > Commits pane. You can see included and excluded changes, and also untracked files. To commit your changes, provide a description (mandatory) and hit the Commit button. The page updates after the commit finishes.

Committing changes

It is possible to view the changes on each file with the built-in tools:

source file diff

After you committed all your changes and you’re ready to publish them on the server you can push the ongoing commits. If there are changes on the server, you must first pull those changes, merge locally, commit again and then push.

push ongoing commits

You can view the history for an entire branch from Team Explorer > Git Changes > Branches

Branch history

or for a single file from Solution Explorer (it is also possible to compare two versions).

File history

, , , Hits for this post: 33920 .

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: The Visual Studio 2005 extensions for.NET Framework 3.0 SP2 (WCF & WPF) (6470).

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

The new C++ standard defines a new keyword, static_assert, that is already available in Visual Studio 2010 CTP. This new feature allows introducing compile time asserts. It takes an expression that can evaluate to bool and a string. If the expression evaluates to false, the compiler issues an error with the given string literal. If the expression evaluates to true, static_assert has no effect.

Here is an example for using static_assert. Suppose you want to create a template vector class, but you don’t want to allow vectors with a size smaller than 4. Then you can use a static assertion to enforce that.

Compiling this program triggers an error at the second declaration.

Most of the use cases for this feature, in my opinion, would be to test on the size of different types. For instance this sample is taken from the C++0x draft.

To me, static_assert looks like a niche feature. It would have been great if this could be used together with some other features to enfore compile time constraints on types. For instance, I want to restrict the possible types for a template class or function to only those that are derived from IListener (a fictive class).

Perhaps a future standard version will offer support for such things.

, , , , , Hits for this post: 47222 .

Lambdas in C++

The new C++0x standard adds lambda expressions to the language. Visual Studio 2010 CTP is already supporting this new feature that brings functional techniques to C++ too.

What is a lambda expression? It’s basically a function. In F# it’s an anonymous function, in C# it’s an anonymous delegate; in C++ it’s in fact an anonymous function object. Whenever you create a new lambda function, the compiler creates a function object for you.

That is equivalent to:

Of course, the lambda functor can be more complicated, when the lambda function captures state from the local scope. However, that is beyond the scope of my post. I recommend that you read more about lambdas in C++ on the VC++ blog.

Question is, what are these lambdas good for? Well, they mostly come in handly with algorithms that take predicates (function objects) as arguments. I’ll try to give you some examples in this post.

Let’s first consider a filter function, that takes a sequence (vector of T) and a predicate that indicates what values should be filtered, and returns a new sequence. That would look like this:

We can use this filter function to extract the odds numbers from a sequence (vector).

You could see in the above example that a second lambda function is used for printing the numbers to the console.

Since the Filter function is a template function it could be used with other types too. In the next example we’ll see how to filter words that have at least 4 letters from a sequence of words.

Let’s consider a second example, a Find (template) function, that takes a sequence and a predicate (that checks a condition for an element), and returns the first element in the sequence for which the predicate returned true.

We’ll use this function to find the first element in a sequence that is greater than a given value.

If you input 4 for instance, it will return 5. If you input 10, an exception will be thrown. You can see that this time the lambda function is [min](int i){return i > min;}. This means that it captures by value the min variable from the local scope, so that it can compare each element with that given value.

The last example I’m going to show is an accumulator function (also known as aggregate or fold). This function takes a sequence of elements, a seed (or initial value) and a function that specifies how to aggregate the elements, and returns the aggregate.

First, we can use it to compute the sum of all elements in a sequence.

The first lambda function above sums the current element with the previous sum, which initially is given as 0. The result is 55. The second lambda function multiplies the current element with the previous product, which initially is 1. The result is 3628800.

But the Aggregate function can be used with other types too. Here is a last example with strings.

These were several examples of how lambda functions help us write more generic, and less verbose code. I suggest you read more about lambdas in C++ here.

, , , , , , , , Hits for this post: 44817 .

So far, C#, unlike C++, did not support optional arguments. For instance, suppose you need a function to print log a message, that can add a new line or not after writing the message. Most of the times you want a new line, so you don’t want to specify that for most of the calls. Until now, the only possibility was using overloaded functions, with different parameters.

C# 4.0, that will be released with Visual Studio 2010, and is for now available with the Visual Studio 2010 CTP, supports, just like C++, optional arguments. So instead of using overloaded functions, you can specify a default value for a parameter. When doing the call, if you don’t provide a value for the argument, the default one will be used.

The Logger class below is identical from the functionality point of view with the one above. (The previous Main() function doesn’t have to change.)

The only restriction is that optional parameters have to appear in the function after all required parameters. In other words, this is not legal:

Considering this implementation of foo

the following calls can be made:

But this is not all. C# 4.0 brings another feature: named parameters (and this does not exist in C++). It means that when you make a call, you can specify an argument by its name, not by position. In this case you use the parameter’s name followed by ‘:’ and the value. Here are several examples:

Of course, this can be used regardless the function has optional parameters or not. However, I would not use this feature for anything else than specifying an optional parameter when I would have to first suply values for other several optional parameters. In other words:

, , , , , Hits for this post: 42404 .

The new C++0x standard provides support for type inference. The auto keyword that was doing nothing in C++ was given a new meaning: a placeholder for a type inferred by the compiler. For those familiar with C#’s var keyword, this is basically the same.

Here is a comparison between auto in C++ and var in C#.

C++ C#

with the output

C++ C#

As you can see, the use is very similar, except that in C++ you can use auto for a lambda expression, while in C# you cannot. The C# compiler raises an error, CS0815, when you try to use var with an anonymous function expressions, a lambda expression, a method group expressions, or the null literal expression, because these don’t have a type.

Just like with var, you can only use auto locally, and not as return type from a function, or parameter to a function.

While it might not be of that much help for ints or strings, using auto for instead of vector< int >::iterator, or map< string, list< string >>::const_iterator comes in handy. The auto type inference helps us write less verbose code.

In addition to auto, the C++0x standard introduces a new keyword, called decltype (think of it as ‘typeof’), that can be used to determine the type of an expression at compile time.

However, this new keyword was not yet introduced in Visual Studio 2010 CTP. According to Stephan T. Lavavej from the VC++ team, it might be possible to be introduced in a next CTP or beta version.

Implementing auto doesn’t implement decltype (C++0x’s name for what was previously called typeof) for free.

Paraphrasing our libraries and compiler front-end program manager Damien Watkins, the CTP is only the first look at our VC10 functionality and there is definitely more to come. We understand that certain features “go together”, and that adding complementary features is a good thing in general. As always, customer feedback is a vital resource in forming our plans.

, , , , , , , , Hits for this post: 59068 .

In a previous post I explained than when you create a MFC application with the March CTP of ‘Orcas’ and add a command or split button to a dialog, the .rc file is not compiled, because styles such as BS_COMMANDLINK are not found. My workaround for the moment was to redeclare them in the resource.h header. But that is not a good idea, because the IDE overwrites the file, removing what you put there. So, eventually, I brought that up to the VC++ team, and it seems that the March CTP has a problem with the resource headers, used by the resource compilers. In other words, at least commctrl.rc was not updated to contain the required definitions.

You can work around this in two better ways:

  • install the Windows RTM SDK, or
  • redefine the necessary styles in commctrl.rc

I decided to go for the second, and now the applications are successfully built. I have been told that the problem has been already fixed for the upcoming CTP/beta. The VC++ team will soon post about this on their blog too. I want to thank to Marian Luparu for the help with this matter.

, , , Hits for this post: 27549 .